Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Facet on metricName with wildcards

facet
wildcards
metric_format

#1

Hi,
I have some metrics (counters/gauges) named like this:

  • hostA.serviceX.partition1
  • hostB.serviceX.partition2
  • hostA.serviceY.partition1
  • hostB.serviceY.partition2
  • hostA.serviceZ.partition1
  • hostB.serviceZ.partition2

I want to have a query with facet on service.

Following this link https://blog.newrelic.com/product-news/nrql-empty-strings-empty-sets-wildcards/ doesn’t help, as if I do FACET metricName, I’ll get 6 facets instead of 3. I saw the use of METRIC_FORMAT somewhere but couldn’t know how to use that in my case.

Could you please help?

Thanks!


#2

Hi, @Huyen.Levan: Try this:

FROM Metric
SELECT average(yourMetricValue)
WHERE appName = 'Your Application'
WITH METRIC_FORMAT '{hostName}/{serviceName}/{partitionName}'
FACET serviceName

#3

Hi @philweber,
Thanks for that, but it doesn’t work for me - all I got back are zeroes. I guess that the problem is what should be put inside the aggregation function (that yourMetricValue)

In the METRIC_FORMAT part I also tried to use slashes ‘/’ instead of dot ‘.’ as per your example but it makes no difference.

FROM Metric
  SELECT sum(`nonprod.op.%.numRecordsOutPerSecond`)
  WHERE appName = 'StreamingApp' and metricName like 'nonprod.op.%.Source%numRecordsOutPerSecond'
  WITH METRIC_FORMAT 'nonprod.op.{hostName}.{serviceTypeName}.{serviceName}.{partition}.numRecordsOutPerSecond'
  FACET serviceName
  TIMESERIES 15 minutes SINCE 1 hour ago

Removing the two lines FACET and WITH METRIC_FORMAT I would get some aggregated data. However, as long as I put the line WITH METRIC_FORMAT in, I’ll get all zeroes.

The raw metrics that we are pushing to NewRelic is like this:

  {
    "name": "nonprod.op.taskManager1-1.streaming.Source: billing.0.numRecordsOutPerSecond",
    "type": "count",
    "value": 0.0,
    "timestamp": 1589596410069,
    "interval.ms": 60783,
    "attributes": {}
  },
  {
    "name": "nonprod.op.taskManager1-1.streaming.Source: playing.0.numRecordsOutPerSecond",
    "type": "count",
    "value": 0.0,
    "timestamp": 1589596410069,
    "interval.ms": 60784,
    "attributes": {}
  },

Here below is the result from my query. That "facets": [] and "unknownGroup" look suspicious

{
  "metadata": {
    "contents": {
      "messages": [],
      "timeSeries": {
        "messages": [],
        "contents": [
          {
            "function": "sum",
            "attribute": "nonprod.op.%.numRecordsOutPerSecond",
            "simple": true
          }
        ]
      }
    },
    "eventTypes": [
      "Metric"
    ],
    "eventType": "Metric",
    "openEnded": true,
    "messages": [],
    "beginTimeMillis": 1589672160000,
    "endTimeMillis": 1589675760000,
    "beginTime": "2020-05-16T23:36:00Z",
    "endTime": "2020-05-17T00:36:00Z",
    "guid": "d1a15a41-313f-8cdf-3633-67b5a1e5ab21",
    "routerGuid": "212f6816-af2b-8456-2e89-ad93a6a715d0",
    "rawSince": "1589672160000",
    "rawUntil": "1589675760000",
    "rawCompareWith": "",
    "facet": "serviceName",
    "offset": 0,
    "limit": 10,
    "bucketSizeMillis": 900000
  },
  "facets": [],
  "unknownGroup": {
    "beginTimeSeconds": 0,
    "endTimeSeconds": 0,
    "timeSeries": [
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589672160,
        "endTimeSeconds": 1589673060,
        "inspectedCount": 0
      },
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589673060,
        "endTimeSeconds": 1589673960,
        "inspectedCount": 0
      },
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589673960,
        "endTimeSeconds": 1589674860,
        "inspectedCount": 0
      },
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589674860,
        "endTimeSeconds": 1589675760,
        "inspectedCount": 0
      }
    ],
    "total": {
      "results": [
        {
          "sum": 0
        }
      ],
      "beginTimeSeconds": 1589672160,
      "endTimeSeconds": 1589675760,
      "inspectedCount": 0
    }
  },
  "totalResult": {
    "beginTimeSeconds": 0,
    "endTimeSeconds": 0,
    "timeSeries": [
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589672160,
        "endTimeSeconds": 1589673060,
        "inspectedCount": 0
      },
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589673060,
        "endTimeSeconds": 1589673960,
        "inspectedCount": 0
      },
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589673960,
        "endTimeSeconds": 1589674860,
        "inspectedCount": 0
      },
      {
        "results": [
          {
            "sum": 0
          }
        ],
        "beginTimeSeconds": 1589674860,
        "endTimeSeconds": 1589675760,
        "inspectedCount": 0
      }
    ],
    "total": {
      "results": [
        {
          "sum": 0
        }
      ],
      "beginTimeSeconds": 1589672160,
      "endTimeSeconds": 1589675760,
      "inspectedCount": 0
    }
  },
  "performanceStats": {
    "inspectedCount": 0,
    "responseTime": 9
  }
}

#4

I think the issue here is WITH METRIC_FORMAT, removing that returns some aggregate metrics as you mention, but I’m struggling to make this work in your account with different attempts at WITH METRIC_FORMAT. I’ll keep looking to see if I can work something out for this, but right now I’m coming up with nothing.


#5

Thank you Ryan. (Sorry I missed your reply). Looking forward to receiving your update.
In the mean time, as of now I am having less than 10 different metrics, so explicitly having them one by one in my query is still fine.

Thanks!


#6

Hi @Huyen.Levan If that is still fine I think that may be best to work with for now.

I have come back to this a few times and have struggled to make it work. So if you have an option that works,I recommend continuing with that.