Skip to content

Commit

Permalink
InfluxDB 2.x, Annotations. Send tags for filtering (#4197)
Browse files Browse the repository at this point in the history
* InfluxDB 2.x, Annotations. Fix: send tags not as fields.

* InfluxDB 2.x, Annotations. Code clean-up

* InfluxDB 2.x, Annotations. Send for Grafana

* InfluxDB 2.x, Annotations. Code clean-up

* InfluxDB 2.x, Annotations. Fix lint

---------

Co-authored-by: Peter Hedenskog <peter@soulgalore.com>
  • Loading branch information
Amerousful and soulgalore authored Jul 25, 2024
1 parent f2d79b1 commit 94854aa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/plugins/influxdb/send-annotationV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export function sendV2(
options.influxdb.includeQueryParams,
alias
).split('.');
let tags = [connectivity, browser, urlAndGroup[0], urlAndGroup[1]];
let tags = [
`connectivity=${connectivity}`,
`browser=${browser}`,
`group=${urlAndGroup[0]}`,
`page=${urlAndGroup[1]}`
];

if (options.slug) {
tags.push(options.slug);
Expand All @@ -55,13 +60,13 @@ export function sendV2(
: Math.round(dayjs() / 1000);
// if we have a category, let us send that category too
if (options.influxdb.tags) {
for (let row of options.influxdb.tags.split(',')) {
const keyAndValue = row.split('=');
tags.push(keyAndValue[1]);
for (const tag of options.influxdb.tags.split(',')) {
tags.push(tag);
}
}
const influxDBTags = getTagsAsString(tags);
const postData = `events title="Sitespeed.io",text="${message}",tags=${influxDBTags} ${timestamp}`;
const influxDBTags = tags.join(',');
const grafanaTags = getTagsAsString(tags.map(pair => pair.split('=')[1]));
const postData = `annotations,${influxDBTags} title="Sitespeed.io",text="${message}",tags=${grafanaTags} ${timestamp}`;
const postOptions = {
hostname: options.influxdb.host,
port: options.influxdb.port,
Expand Down

0 comments on commit 94854aa

Please sign in to comment.