Add a binary field to Prometheus records

I’m currently working with InfluxDB 2.7 and using a Blackbox Exporter to capture metrics in the style of Prometheus (all in Docker containers). However, I’m facing a challenge where I need to add a binary field to each individual record, for example, to store a value for the additional field ‘isCorporate’. I’ve done some research but haven’t found a clear guide on how to accomplish this.
The binary field is important to me to filter the data set in Grafana.

Can someone please explain how I can achieve this? What steps do I need to take to add this binary field to my records? Thank you for your help in advance!

Hello @joseph2374,
It depends on how much data you have. You can’t update your data in InfluxDB you can only overwrite your data. You could:

  1. query your data with a client library, add a binary tag and then write it back to InfluxDB. This is an option if you have a ton of data and you want a permanent tag
  2. you could add a binary column or tag as a result of your query (not actually written to influxdb with conditional map statement)
|> map(
        fn: (r) => ({r with
            binary: if r._value == "isCorporate" then 1

assuming you’ve filtered for that field.

  1. You could do the same as in 2. but then write the data back to influxdb with the to() function. This works if you’re looking to do it for smaller amounts of data.
    to() function | Flux 0.x Documentation