k6

Save data from response body to InfluxDB

Is there a way to save data from response body to InfluxDB?

Background: Our web service returns a uuid as a part of response body. Right now our k6 script just writes them to console with console.log(), but if there is an easier way to store them in InfluxDB, it is more desirable for post-processing. Although I had thought it would be possible by defining a custom metrics, so far I could not find a good way.

Tami (Masaaki) Takamiya

I would recommend that you add a (user defined) tag with the uuid as a value.

Given that you get it from the request, you can’t just add it to the metrics of that request, but you can add it to the metrics of either a check() for that request or a custom metric, even one specifically for putting that uuid in the influxdb.

I would also have to add that influxdb does have some … problems with a lot of unique tag values which is why we have (somewhat undocumented) feature to not send some tags as tags but instead as fields to influxdb.

As uuids are one the things specifically listed as not good candidates for tags you should probably use the tagsAsFields feature. Adding environmental variable like K6_INFLUXDB_TAGS_AS_FIELDS=vu,iter,url,uuidTagKey should do the trick(Don’t forget the vu,iter,url as they are also highly different in values).

1 Like

mytoykov,

Sounds like user defined tag + K6_INFLUXDB_TAGS_AS_FILEDS is what I was looking for. I will try what you suggested. Thank you very much.

Tami (Masaaki) Takamiya