xk6-output-timescaledb icon indicating copy to clipboard operation
xk6-output-timescaledb copied to clipboard

Tagged thresholds improperly saved in the TimescaleDB's threshold table

Open viginti23 opened this issue 3 years ago • 3 comments

As mentioned it the title, when passing tagged metrics in thresholds like so: 'http_req_duration{name:login}': ['p(95)<55000'],

they are not saved properly in the database, namely the metrics are not separated from their tags and the 'tags' column in the threshold table is populated with nulls.

viginti23 avatar Oct 27 '22 13:10 viginti23

I did some digging and ... ughh.

So the column tags was removed as part of https://github.com/grafana/xk6-output-timescaledb/pull/1 in specifically https://github.com/grafana/xk6-output-timescaledb/commit/a73723cad14e0f59818c69ba574ded942a6d1d31 which in practice dropped it.

Later when I had to make this runnable I readded the column ... I think because there was a query that used it and it was failing the whole dashboard

I kind of wonder if it's needed even :shrug:

I kind of feel like dropping the whole column again and removing it usage :thinking:

We will need to readd the parsing of the threshold. Which might not work in the future if we add more stuff in k6. Maybe we should have the tags accessible from the Threshold directly from k6 :shrug:.

cc @javaducky do you have any input here?

@viginti23 what do you want to use that column for? Does it make sense to have it at all? I mean it seems like we will always want to show the whole name(including the metric name).

I guess if you have a lot of thresholds it might be nice to query based on tags and or metric not the two at the same time :thinking: But seems kind of niche to me and still doable without the column.

mstoykov avatar Oct 27 '22 14:10 mstoykov

Hi, I think you are right, looks like there might not be any need for that column (at least at the moment :) ).

viginti23 avatar Oct 31 '22 10:10 viginti23

In my case I want the tags column to be filled with at least the testid field (that is passed when executing the k6 script) so that the graph for the checks can be more accurate. For example at the moment this is the query for the thresholds graph:

SELECT
  CASE WHEN "tags" IS NULL THEN "metric" ELSE "metric" || '{' || (SELECT key || ':' || value FROM jsonb_each_text("tags")) || '}' END,
  "threshold",
  CASE WHEN "last_failed" THEN 0 ELSE 1 END AS pass_fail
FROM
  thresholds
WHERE
  $__timeFilter(ts)
ORDER BY 3 ASC
LIMIT 100

The problem with this is when I'm checking out a specific test id, this won't show the correct thresholds for that test id. I'm expecting to be able to filter the thresholds by test id like this:

SELECT
  CASE WHEN "tags" IS NULL THEN "metric" ELSE "metric" || '{' || (SELECT key || ':' || value FROM jsonb_each_text("tags")) || '}' END,
  "threshold",
  CASE WHEN "last_failed" THEN 0 ELSE 1 END AS pass_fail
FROM
  thresholds
WHERE
  $__timeFilter(ts)
AND tags->>'testid' = '$k6_testid'
ORDER BY 3 ASC
LIMIT 100

danhngo-lx avatar Nov 14 '24 07:11 danhngo-lx