Characteristics of Metrics and Events in New Relic and queries in NRQL

newrelicmonitoring

New Relic categorizes telemetry data into Metrics, Events, Logs and Traces, called MELT. Sent data can be queried in NRQL, standard SQL-like queries, shown on a dashboard, and targeted as alert conditions, but sometimes desired value can’t be obtained depending on the data type.

Metrics

Periodically aggregated and sent data. Having aggregated data, the transfer cost can be reduced and track the long-term trend, but there is a trade-off that the information required to aggregate later is lost.

dimensional metrics

Aggregated values, which are attached with some metadata such as resource information. type is the metrics type such as summary, count and gauge, and depending on it, contained fields and available aggregate functions are different. For example, if type is summary, min(), `max() and average() etc. can be used but percentile() is not available.

// SELECT `aws.elb.Latency` FROM Metric WHERE `aws.elb.Latency` IS NOT NULL
{"type":"summary","count":123,"sum":0.04,"min":0,"max":0.001}
...

// SELECT keyset() FROM Metric WHERE `aws.elb.Latency` IS NOT NULL
{
    "stringKeys": [
        "aws.Arn",
        "aws.MetricStreamArn",
        "aws.Namespace",
        "aws.accountId",
        "aws.elb.AvailabilityZone",
        "aws.elb.LoadBalancerName",
        "aws.elb.Service",
        "aws.elb.canonicalHostedZoneName",
        "aws.elb.canonicalHostedZoneNameId",
        "aws.elb.dnsName",
        "aws.elb.scheme",
        "aws.elb.vpcId",
        "aws.region",
        "collector.name",
        "displayName",
        ...
    ],
    "numericKeys": [
        "endTimestamp",
        "timestamp"
    ],
    "booleanKeys": [],
    "summaryKeys": [
        "aws.elb.Latency"
    ],
    ...
}

Events

Data for each event such as Transactions of APM. Contrary to Metrics, the transfer cost is high, but various aggregations can be performed.

// SELECT request.uri, totalTime FROM Transaction
{
    "events": [
        {
        "timestamp": 1654364052164,
        "request.uri": "/path",
        "totalTime": 0.000124612
        },
        ...
    ]
}

// SELECT percentile(totalTike, 95) FROM Transaction FACET request.uri
{
    "facets": [
      {
        "name": "/path",
        "results": [
          {
            "percentiles": {
              "95": 0.0000125
            }
          }
        ],
        "beginTimeSeconds": 0,
        "endTimeSeconds": 0
      },
      ...
    ]
}

Can be converted to Metrics with a function such as summary().

// SELECT summary(totalTime) FROM Transaction WHERE request.uri = '/path'
{
    "count": 4073,
    "total": 314.2522969348,
    "min": 0.000018678,
    "max": 72.14054709
}

参考

Metrics, Events, Logs, Traces ってなんだ?