Following is how my schema is set up.
single_data_point = influxdb_client.Point(“alerts”)
.tag(“operator”, msg_dict[‘operator’])
.tag(“app_type”, msg_dict[‘app_type’])
.tag(“app_name”, msg_dict[“app_name”])
.tag(“app_host”, msg_dict[‘app_host’])
.tag(“datacenter”, msg_dict[‘datacenter’])
.tag(“alert_type”, msg_dict[‘alert_type’])
.field(“comment”, msg_dict[‘comment’])
The following is the visualization I want to make on this data.
What would the query for this be?
Hello @omkudalkar9,
Couple of things,
- I really appreciate you spending the time to make this.
- I like your handwriting.
Quick question? What are you expecting to get the count of? The number of comments that are of alert-type 1?
Alright lets get to it. I’m assuming you’re using 2.x and Flux. Since you use alert_type as a tag, the data will automatically be grouped across those alert types.
I believe your query should look like this:
from(bucket: "<your bucket>")
|> range(start: <start time>, stop: <stop time>
|> filter(fn: (r) => r["_measurement"] == "alerts")
|> filter(fn: (r) => r["_field"] == "comment")
|> filter(fn: (r) => r["alert_type] == "1" or r["alert_type] == "2" or r["alert_type] == "3")
|> count()
|> yield(name: "comment count grouped by alert type")
PS do you come from a SQL background? If so this might be helpful: