flightstats / node-insights

Submit data to New Relic Insights
7 stars 1 forks source link

Flatten array data in a less ugly way #17

Open mattpage opened 9 years ago

mattpage commented 9 years ago

Since I have been asked about this more times than anything else:

[from the README]

Array data flattens out too:

  insights.add({
    'randomWords': [ "card", "bean", "chair", "box" ]
  });

but it is less pretty:

{
  'appId': 42,
  'eventType': 'data',
  'randomWords.0': 'card',
  'randomWords.1': 'bean',
  'randomWords.2': 'chair',
  'randomWords.3': 'box'
}

Maybe array data should NOT be flattened with indexes? Alternative representations?

gvilarino commented 8 years ago

As long as NR is a key-value-pair storage, I don't see a way of avoiding this.

Another approach would be to (optionally?) store a comma-separated list of values when:

  1. array elements are "native" values (i.e.: string, number, etc.)
  2. that cs list doesn't go over 1MB in size (NR limit)
mattpage commented 8 years ago

@gvilarino that's not a bad idea. It might be more difficult to report on inside of Insights, nrql query subindexes? That said, I don't see much value in adding it at this point. I would prefer to wait for someone, who actually wanted that format to PR it.