assume next 2 prometheus timeseries:
service_deployed{service} timestamp
service_available{service} timestamp
A set of specific metrics with matching labels would be:
service_deployed{service='provision-service'} 12345678.0
service_available{service='provision-service'} 12345900.0
which in effect say that there is a newer 'provision-service' (as its available timestamp is greater than the deployed one).
Now imagine I'd like to present these 2 in one table in Grafana. Something like:
| Service | Deployed | Available |
| provision-service| 12345678.0 | 12345900.0|
Also assume that I cannot use the latest Grafana (>5.0) that seems to be able to combine tables so I'll have to do this using promQL. How would you go about combining these metrics?
Thanks
Related
I am using Grafana to perform a Log to Metric query using an Azure Data Explorer datasource, that gives me a result like this as a table:
This comes from this query:
Log
| where $__timeFilter(TIMESTAMP)
| where eventId == 666
| summarize count() by bin(TIMESTAMP, 15m), Region
| order by TIMESTAMP asc
When rendered as a timechart in AppInsights, it renders perfectly like this:
However in Grafana, this perplexingly renders by the Count_ column, not using the obvious Regional breakout field:
My goal is to get an AppInsight's like timechart with multiple data series, within Grafana
I found my answer! It turns out I was rendering the data as a Table, using the Grafana query wizard here.
Once I changed that to TimeSeries, it all just worked!
I've been work on Loki for centralized logging with Grafana. I want to 'Explore' log by query without using time control on top of the Grafana. I wonder if its possible to add range time manually by query (not the time control provided by grafana)?
It's probably like
{job=docker-container} |~ "error" | startsAt = formatTime | endsAt = formatTime
I didn't found any variables that can describe control time range though, also for the labels
When I have a Prometheus query resulting in:
my_metric{instance="instance1",job="job",prop_1="ok",prop_2="cancel"} 1
my_metric{instance="instance2",job="job",prop_1="error",prop_2="ok"} 1
How can I create a Grafana table showing:
timestamp | instance1 | ok | cancel
timestamp | instance2 | error | ok
So a Prometheus metric property is mapped to Grafana table column.
OPEN QUESTION: Is it possible to change the value of a tag dynamically? So the 3rd and 4th label (or property) values change over time.
QUESTION 1: The first part of the question is simple: Formatting the prometheus labels/properties in a table is easy. The answer you can find in this description.
How? Just select the 'table' format as shown in the second red box.
QUESTION 2: any idea?
I am having a setup collecting metrics from telegraf into influxdb. Then grafana uses influxdb as data source to display graphs.
My problem is reducing disk usage, so I want to downsample old data (older than 3 days) and keep the new data (younger than 3 days) as is (raw)
I tried Retention Policy (RP) of influxdb and Continuous Queries (CQ) as described in guide:
https://docs.influxdata.com/influxdb/v1.2/guides/downsampling_and_retention
influxdb ("telegraf")
+----------------------------+
| |
| +-----------------------+ |
| | table disk_raw | |
| | CURRENT RP (RAW) +---------+
| | (deleted after 3d) | | |
| +-----------------------+ | |CQ (average 30 min of datapoints into 1)
| +-----------------------+ | |
| | table_disk_ds | | |
| | LONGTERM RP +<--------+
| |(downsampled, kept 90d)| |
| +-----------------------+ |
| +<----+
+----------------------------+ |
|
|
grafana | grafana query
+----------------------------+ |
| | |
| +----------------------+ | |
| | data graph | +-----+
| +----------------------+ |
| |
+----------------------------+
The problem is - this solution is giving you 2 tables, one for raw data and one for downsampled data. CQ is constantly writing out to downsampled data.
That is not so good for me as:
I am using grafana to query influxdb and it reads from single table
to the graph. And I want one graph for both old data and new data.
Using 2 databases increases disk usage
Is there any way to downsample old records in the very same table?
configuring example:
https://docs.influxdata.com/influxdb/v1.2/guides/downsampling_and_retention
grafana query
SELECT mean("used_percent") FROM "disk" WHERE ("device" = 'dm-0') AND $timeFilter GROUP BY time(10s) fill(none)
EDIT2: Here's a workaround implemented with template variables in Grafana
https://github.com/grafana/grafana/issues/4262#issuecomment-475570324
This seems like a really good solution.
ORIGINAL ANSWER
Looking into the example from the influxb page you linked
CREATE CONTINUOUS QUERY "cq_30m" ON "food_data" BEGIN
SELECT mean("website") AS "mean_website",mean("phone") AS "mean_phone"
INTO "a_year"."orders"
FROM "orders"
GROUP BY time(30m)
END
If you specify the same source and target table, namely orders, into both INTO and FROM clauses then the data will be written to the same table.
However, that does not solve your issue.
You would still need two queries to get the data from both retention policies. If you do a generic select * from disk_raw ... Influx will use the default retention policy and return data just from there.
The way you usually go about this is by running two queries and concatenating the results. In a single request something like
select * from rp_short.diskraw; select * from rp_long.diskraw
EDIT:
Here is a discussion of why it's not possible to do what you (and a lot of other people) want https://github.com/influxdata/influxdb/issues/2625
And also some ways to work around it.
Briefly, one way is to handle the downsampling and high resolution data manually (i.e not with CQ) and keep it in the same retention policy. Another is to use a proxy that would augment the query depending on the time range of the query in order to get the correct data.
Using the Prometheus plugin, is it possible to show single statistics in a table as key:value table rows in stead of time series?
This means the current_value only.
E.g. node_uname_info giving:
key | value
------- |-------
machine | x86_64
nodename| ServerName
release | 4.10.51-1-amd64
sysname | Linux
version | #1 SMP Debian 4.10.51-1
Preferably I want to manually select one value per table row from different sources. E.g.:
A: node_uname_info.release
B: node_uname_info.version
C: "Some Manual String"
D: node_memory_MemTotal
As of Grafana 4.3, indeed you can:
http://docs.grafana.org/guides/whats-new-in-v4-3/#prometheus-table-data-column-per-label
But column C in your example, containing Some Random String, will be hard to accomplish in Grafana. Consider using Prometheus relabeling to permanently add additional data to you metrics in Prometheus.