...
The Service stores metrics data to an InfluxDB service with a default retention policy of 24 hours. This may not be long enough time for your use cases. This document will show with examples how to store metrics data for a longer period of time, and how to configure Grafana to display it.
Table of Contents |
---|
The theory
To store measurements for a longer time, it must be stored with a Retention Policy of desired length. It doesn’t make sense to store ALL data for the specified time: When Grafana shows values from a month in a graph, it physically cannot display data at 50 millisecond accuracy. Having a lot of data at very short intervals takes a lot of processing, bandwidth and disk space. So you must think about downsampling the data as well.
...
This existing continuous query data can be used in Grafana with the following configuration:
...
Creating a custom RP and CQ
Let’s suppose there isn’t a CQ and RP that meet our requirements.
Requirements
We need to have a Grafana display which shows Management API request counts by path, and we need to show data for the last 30 days.
What we already have
We can show a graph for the last 24 hours with the following Grafana Panel configuration:
...
The essential info we see from this configuration is:
Data is stored with the default retention policy (which we know is
one_day
by using theshow retention policies
command) with measurement namemgmg_api_request
.There’s a field or tag called
auth_header_exists
, and in this graph we display the number of them by using thecount()
function.We group by time and also the tag
path
.The
path
tag is also used as an alias, the value of which is shown in the legend.
Create a Retention Policy
We need a retention policy that is at least 30 days long. Let’s see what is available:
Code Block |
---|
> show retention policies
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 0s 168h0m0s 1 false
five_years 43680h0m0s 168h0m0s 1 false
one_day 24h0m0s 1h0m0s 1 true
one_year 8736h0m0s 168h0m0s 1 false |
We see that one_day
is indeed the default, and the next longest is one_year
. Since that is too long, we should create a new RP called one_month
that has a duration of 30 days, or 720 hours.
Code Block |
---|
> CREATE RETENTION POLICY "one_month" ON "oneportal" DURATION 720h REPLICATION 1 |
Now we can confirm that it was added.
Code Block |
---|
> show retention policies
name duration shardGroupDuration replicaN default
---- -------- ------------------ -------- -------
autogen 0s 168h0m0s 1 false
five_years 43680h0m0s 168h0m0s 1 false
one_day 24h0m0s 1h0m0s 1 true
one_year 8736h0m0s 168h0m0s 1 false
one_month 720h0m0s 24h0m0s 1 false |