Search code examples
influxdbgrafana

Trying to figure out influxdb with Grafana but I'm doing something wrong


Right, so I've got a script polling folder size and putting it into influxdb

Measurement = "job_size"
Tag Key = "path"
Value = the size in KB

enter image description here

I can't seem to get this going in grafana for some reason. Could possibly be the query I'm using? Right now I'm just using SELECT * FROM job_size but it's only returning a single entry from "job_size"

enter image description here

Any ideas what I'm doing wrong here ? Should I be writing it into the DB differently?


Solution

  • I tried to reproduce your problem with the following steps. I hope this helps you to detect where you are doing something wrong.

    Insert your data into influxdb

    I did a quick test by creating a new db and inserted some points via line protocol:

    influx
    CREATE DATABASE stackoverflow_test
    USE stackoverflow_test
    INSERT job_size,path=test value=100000
    INSERT job_size,path=test value=200000
    INSERT job_size,path=test value=300000
    

    Check if the data got inserted via the admin UI:

    enter image description here

    The grafana query:

    enter image description here

    You can see in my screenshot that my query works like expected. But If I change the query to use the '*' operator like you did in your screenshots I get no results. So avoid doing something like:

    SELECT "value" 
    FROM "job_size" 
    WHERE "path" = '*' 
    

    And go with:

    SELECT "value" 
    FROM "job_size" 
    WHERE "path" = 'test' 
      AND "path" = 'othertest' 
      AND ...
    

    or if you want to select all path keys just go with:

    SELECT "value" FROM "job_size"