How to query for metrics added using HTTP rest API metric-api metric/v1

Hey,

Super new with new relic so apologies for the noob question.

I’ve submitted a metric value using the metrics REST API –

curl -vvv -k -H "Content-Type: application/json" \
-H "Api-Key: ${KEY}" \
-X POST "${NEW_RELIC_URL}/metric/v1" \
--data '[{
       "metrics":[{
       "name":"foo.bar.baz",
       "type":"boolean",
       "value":0,
       "timestamp":'"${TS}"',
       "attributes":{"foo":"bar"}
       }]
}]'

I get a 202 - Accepted back, which I assume indicates success.

Then I go into the query builder on one.newrelic.com and search for select * from Metric but don’t see anything. What am I doing wrong?

Hi, @max5: You may query NrIntegrationError events to see if there was a problem parsing your JSON payload.

1 Like

Hey @philweber, thanks for the reply!

I’ve done select * from NrIntegrationError but that’s also empty. Is there some other way I should be querying?

SELECT * FROM NrIntegrationError will only show errors for the past hour. Try SELECT * FROM NrIntegrationError SINCE 1 week ago.

I see. Unfortunately I still get no events found. I’m using the query builder at insights.newrelic.com from the same area/account that I generated my api key.

OK, I am out of ideas. Hopefully a support engineer will be along to assist shortly.

No worries. Appreciate the help. I’m sure it’s something silly I’m doing, since I’m incapable of getting the simplest thing working. Hopefully someone will be along shortly to point out my silliness :slight_smile:

If you would like to send me your exact curl command in a private message, I am happy to try it in my account and see if I can find the problem.

OK, found the problem: boolean is not a supported metric type. :slight_smile: Metrics may only contain numeric values; you must specify a type of gauge, count, or summary.

The following curl command works for me:

curl -H "Content-Type: application/json" \
-H "Api-Key: ${INSIGHTS_INSERT_KEY}" \
-X POST https://metric-api.newrelic.com/metric/v1 \
--data '[{ 
  "metrics":[{ 
    "name":"foo.bar.baz",
    "type":"gauge",
    "value":0,
    "timestamp":1597440519,
    "attributes":{"foo":"bar"}
  }] 
}]'

Hey Phil, thanks so much for the help. This was exactly the problem. The 202 had me confused.