Skip to content

Instantly share code, notes, and snippets.

@mmastoras
Last active March 30, 2020 19:39
Show Gist options
  • Save mmastoras/892881008d32240696be3a076ecb8a9c to your computer and use it in GitHub Desktop.
Save mmastoras/892881008d32240696be3a076ecb8a9c to your computer and use it in GitHub Desktop.
Influx cheatsheet
$ influx -ssl -host <host> -port <port>
# select database
> use <database name>
# set time format
> precision rfc3339
# show all measurements
> show measurements
# select data from measurement
> select * from "<measurement name>" order by time DESC limit 10;
# use inner join to select a tag, in this case hostname is a tag and can only be retrieved when selected w/ a non-tag
> select "hostname" from (select last("BytesInPerSecCount"), "hostname" from "kafka.topic" where time > now() - 5m group by "hostname");
# group by examples in granfa dashboards
SELECT mean("BytesInPerSecOneMinuteRate") as "BytesIn" FROM "kafka.topic" WHERE $timeFilter GROUP BY time($interval),"topic" fill(null)
SELECT mean("TotalFetchRequestsPerSecCount") as "FetchRequests" FROM "kafka.topic" WHERE $timeFilter GROUP BY time($interval), "topic" fill(null)
SELECT mean("TotalProduceRequestsPerSecCount") as "ProdReq" FROM "kafka.topic" WHERE $timeFilter GROUP BY time($interval), "topic" fill(null)
> select * from "kafka.topic" where "topic" = 'container_logs_alpha' order by time DESC limit 5;
## alert when cluster status !=green set alert to trigger if value > 0
> SELECT count("status") FROM "elasticsearch_cluster_health" WHERE ("host" =~ /search6-ds-coordinator1/) AND "status" =~/'yellow|red/ AND $timeFilter GROUP BY time($__interval) fill(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment