skip to Main Content

I trying to plot memcached data in influxdb + grafana and i found ps_cputime is in microsecond.

How do i convert it in human readable format so easy to understand.

influxdb:

> select * from memcached_syst limit 10;
name: memcached_syst
time                host                                         type       value
----                ----                                         ----       -----
1549595956627272659 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15853819249
1549596016550515653 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15853923573
1549596076550356985 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854047878
1549596136550415911 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854165969
1549596196550481720 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854288341
1549596256550522792 ostack-infra-01_memcached_container-167ecaa7 ps_cputime 15854387422

Grafana query:

SELECT mean("value") FROM "memcached_syst"  WHERE ("host" =~ /^$host$/ AND "type"='ps_cputime' ) AND $timeFilter GROUP BY time($interval) fill(null)

what i can do here to make it in parcent?

2

Answers


  1. You need to use NON_NEGATIVE_DERIVATIVE, result will be in percentage:

    SELECT NON_NEGATIVE_DERIVATIVE("value", 1s) / 1000
    FROM "memcached_syst"
    WHERE ("host" =~ /^$host$/ AND "type"='ps_cputime' ) AND $timeFilter
    GROUP BY time($interval) fill(null)
    

    This query may need some tuning, for example normalization by the number of cores.

    Login or Signup to reply.
  2. You can convert microseconds to hours and display the result.
    Formula to convert to hours – microseconds / 3600000000

      Select (column_name/3600000000)      as time_in_hrs from table_name;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search