Custom event/metric naming syntax & hyphens

The documentation has this description of naming syntax:

Naming syntax:
Attribute names can be a combination of alphanumeric characters, colons ( : ), periods ( . ), and underscores ( _ ).

Event types (using the eventType attribute) can be a combination of alphanumeric characters, colons ( : ), and underscores ( _ ).

Note that it makes no mention of the hyphen character, but I have found (accidentally) that I can create both event type names and metric categories and names that include hyphens, and that they are found in both Insights and New Relic One.

Is the documentation just offering guidance here, and not defining legal characters for names? Or, is it in need of an update? Are there other unmentioned characters that are also legal?

Hey @jamartin - You shouldn’t be able to create events with hyphens in the event name…

I just tested sending this data to my own account:

[
   {
      "eventType":"ryans-test",
      "test-attribute":3,
      "other-test-attribute":259.54
   },
   {
      "eventType":"ryans_test",
      "test_attribute":5,
      "other_test_attribute":12309
   }
]

In Insights, and in the New Relic One Chart Builder there is no sign of the hyphenated event, only the underscored.

image


Can you share an example of how you got a event name in with hyphens? I’m sure that shouldn’t be possible so I’d love to dig deeper into your example.

2 Likes

Ah - actually, it looks like I was able to create hyphenated custom metric category names with hyphens, not custom event type names.

I can see now that the documentation doesn’t include any description of restrictions on legal characters in custom metric names - looks like I wrongly conflated the two. I am curious though why events would have this naming constraint but metrics wouldn’t?

Gotcha! That makes more sense. Thanks for confirming it’s events instead of metrics that are limited by hyphens. That sort of helps narrow down why that may be.

I’m not 100% certain of this, but I imagine this is some limitation (I don’t know if it’s by design or not) within NRDB, the New Relic custom Database.

NRDB houses all event based data, it does not host metric data, so metrics wouldn’t have that same limitation. NRDB would be the biggest difference between metrics and events, so I’m guessing that’s what’s causing the blocker there.

Can you work around this with underscores rather than hyphens in your events?

1 Like

I had changed everything to underscores already, but had missed some metric names, which is how I came across the difference. It’s not a big deal, I’m just aesthetically more attracted to hyphens than underscores is all.

1 Like

You and me both :joy:

Thanks for getting those updated though, glad that works for you even if it is ugly in appearance :smiley:

1 Like

This is where I got the impression that custom metrics follow the same rules:

https://docs.newrelic.com/docs/data-ingest-apis/get-data-new-relic/metric-api/metric-api-limits-restricted-attributes

…didn’t realize these are completely different from APM custom metrics. I’m still pretty foggy on the constellation of apis and products around reporting and charting events and metrics. I don’t think I have a good handle on this yet.

Yep! Terminology can be a nightmare at times, you’re right though that the ‘metrics’ defined in that doc aren’t quite the same as custom metrics sent in by the APM Agent APIs.

If there’s anything more I can clarify for you, let me know.

1 Like

It’s worth noting that we discovered putting a hyphen in metrics monitored by nri-flex actually causes Infrastructure problems.

When creating an alert condition in Infrastructure it will fail to show the preview graph and fail to create the condition. It actually generate invalid NRQL for the alert:

{“query”:“SELECT average(test-hyphen-4xx), latest(entityName) FROM TestSample FACET entityName SINCE 3600 seconds ago TIMESERIES”}

So things don’t work as expected. Of course we’ve changed things back but perhaps this is a bug if the platform is accepting them and it breaks the alerts control panel.