Adding up values for a pie chart in grafana - grafana

What are you trying to achieve?
I want to build a pie chart that shows the percentage of the time my robot was in a specific status-mode, pretty much like the image shows:
example pie chart
I want it to monitor the status over the whole history, so i can see after multiple months what my robot did the most and what it did less.
For example: if it runs 100 seconds and was charging 50s, sleeping 25s and walking 25s, it should result in my example graph.
How are you trying to achieve it?
I’ve written a c# programm to insert data in the following format, whenever the status of the robot changes: “Status,Status=“Walking” Duration=50”
So in the example, that would mean that the robot walked for 50 seconds, then switch status to maybe charge or sleep. As soon as he switched status, the duration of the previous status gets send to the influxdb and the duration counter starts ticking for the following status.
What happened?
My problem: i want to add up all the values for “walking”, “sleeping” and “charging” in grafana, so that i result in a total walking-time etc., so that i can show how long it did what.
So the robot ist walking for 10 seconds, then charging for 20s and then walking for 10s again, it should be a pie chart showing 50% walking and 50% charging.
Is there a way to achive this in grafana and influxdb? i could also change up the data format if needed…
thanks in advance for your help, im really a beginner with grafana and influxdb and its driving me crazy

You need a query in the Grafana:
SELECT sum("duration")
FROM "<measurement>"
WHERE $timeFilter
GROUP BY "status"
Keep in mind that status is a InfluxDB tag, duration is a InfluxDB field. Check InfluxDB documentation what is a field/tag.

Related

Grafana how to show status of a system as "Running" if recent log entries have been created

I want to create a simple Grafana dashboard that shows if a system is running. To detected the run state, I look at the log rate. The system is continuously writing log files if it is running. If no logs files found in last 5 minutes, I would like to make the LED red. For this I need the LogQL return a single metric, like "log files from last 5 minutes".
How to do that?
I tried:
sum(count_over_time({job="systemname"}[1m])) > 0
This gives a nice timeline graph but for all the past, not just recently.
How can I make a single value from it?
I tried to apply a fix range (last 5 minutes) but this is not a valid query:
sum(count_over_time({job="systemname"}[1m][5m])) > 0
In the end, I would like to have an output like <number greater than 0> for running, 0 for not running. This way I could create a simple table and color the cells with a color range.

read the Data from internet (like Chart of BTC)

is there any way to read the Data from internet (like Chart of BTC) on one device normal speed and on the other device 1 minute later ??
for example BTC chart on Metatrader4 or like (Every minute) that i want to see the normal chart
on the other Device i need to see the same Chart but with 1 minute later
so with more PING or like that

In mustache from a kibana trigger message, is there a way to get the exact date that's x days before ctx.periodStart's timestamp?

I'm trying to use a kibana trigger from a monitoring alert using the message box to formulate a kibana link that sends it to a specific kibana dashboard for a time period of the last 7 days from the time the alert is triggered and send it to a slack webhook.
I'm using the ctx.periodStart variable as my ending period. Is it possible to get the exact timestamp that's 7 days from the ctx.periodStart timestamp as part of my kibana trigger message (In other words, if the ctx.periodStart timestamp is 2022-04-11T19:19:25Z as my period ending range, I want to have the beginning timestamp value at 2022-04-04T19:19:25Z)? I can't seem to find anything that can do this. The only way around this issue is to use the ctx.results.0.hits.hits.0._source.timestamp variable as my starting period and that timestamp value is a bit earlier than the exact 7 days from the ctx.periodStart timestamp. Using a relative time period (like now-7d) isn't going to cut it because we fire this kibana monitor alert every Friday at noon to grab a query where we know we will get at least 1 hit and every Tuesday at midnight where we know we are not likely to get any results from the query. And since we know that this alert will go to a slack message with the kibana dashboard link once a week, putting a relative time period like 'now-7d' is going to mess up the kibana links for past slack alerts from the same kibana monitoring alert.
Thanks.

How to make sense of the micrometer metrics using SpringBoot 2, InfluxDB and Grafana?

I'm trying to configure a SpringBoot application to export metrics to InfluxDB to visualise them using a Grafana dashboard. I'm using this dashboard as an example which uses Prometheus as a backend.
For some metrics I have no problem figuring out how to create graphs for them but for some others I don't know how to create the graphs or even if it's possible at all. So I enumerate the things I'm not really sure about in the following points:
Is there any documentation where a value unit is described? The application I'm using as an example doesn't have any load on it so sometimes I don't know whether the value is a bit, a byte, a second, a millisecond, a count, etc.
Some measurements contain the tag 'metric_type = histogram' with fields 'count', 'sum', 'mean' and 'upper'. Again, here I don't know what the value units are, what upper means or how I'm suppose to plot them. Examples of this are 'http_server_requests' or 'jvm_gc_pause'.
From what I see in the Grafana dashboard example, it seems I should use these measurements of type histogram to create both a graph with counts and graphs with duration. For example I see I should be able to create a graph with the number of requests and another one with their duration. Or for the garbage collector, I should be able to provide a graph for the number of minor and major GCs and another for their duration.
As an example of measures I get inserted into InfluxDB:
time count exception mean method metric_type outcome status sum upper uri
1625579637946000000 1 None 0.892144 GET histogram SUCCESS 200 0.892144 0.892144 /actuator/health
or
time action cause count mean metric_type sum upper
1625581132316000000 end of minor GC Allocation Failure 1 2 histogram 2 2
I agree the documentation for micrometer is not great. I've had to dig through the code to find answers...
Regarding your questions about jvm_gc_pause, it is a Timer and the implementation is AbstractTimer which is a class that wraps a Histogram among other components. This particular metric is registered by the JvmGcMetrics class. The various measurements that are published to InfluxDB are determined by the InfluxMeterRegistry.writeTimer(Timer timer) method:
sum: timer.totalTime(getBaseTimeUnit()) // The total time of recorded events
count: timer.count() // The number of times stop has been called on the timer
mean: timer.mean(getBaseTimeUnit()) // totalTime()/count()
upper: timer.max(getBaseTimeUnit()) // The max time of a single event
The base time unit is milliseconds.
Similarly, http_server_requests appears to be a Timer as well.
I believe you are correct that the sensible thing is to chart on two separate Grafana panels: one panel for GC pause seconds using sum (or mean or upper), and one panel for GC events using count.

Lead Time and Cycle Time - Connect to Analytics with Power BI Data Connector

I'm trying to validate the data between the widgets Lead Time and Cycle Time with the report that imported from azure devops (https://learn.microsoft.com/en-us/azure/devops/report/powerbi/data-connector-connect?view=azure-devops), but when I do the average the data doesn't match. Is there some place where can I find information about how the calcule is done or which filters to perform?? Isn't that a simple average?
Lead Time Exemple
As far as I know, the lead time and cycle time will also include weekends. So this could affect the average of the data.
From this doc:
Lead time is calculated from work item creation to entering a completed state. Cycle time >is calculated from first entering an In Progress state to entering a Completed state.
In PowerBI, you could check the Completeddate , Cycletimedays column,CompletedDate.
For example:
In chart:
Chart settings:
In Date:
The average Cycle time days:(147.183+133.340+133.340)/5 = 82.77
Here is a doc about creating Power Bi lead time/ cycle time chart.