Using grafana counter to visualize weather data

I'm trying to visualize my weather data using grafana. I've already made the prometheus part and now I face an issue that hunts me for quite a while.

I created an counter that adds temperature indoor every five minutes.

var tempIn = prometheus.NewCounter(prometheus.CounterOpts{
    Name: "tempin",
    Help: "Temperature indoor",
})

for {
   tempIn.Add(station.Body.Devices[0].DashboardData.Temperature)
   time.Sleep(time.Second*300)
}

How can I now visualize this data that it shows current temperature and stores it for unlimited time so I can look at it even 1 year later like an normal graph?

tempin{instance="localhost:9999"} will only display added up temperature so its useless for me. I need the current temperature not the added up one. I also tried rate(tempin{instance="localhost:9999"}[5m])

How to solve this issue?

1 answer

  • answered 2022-04-24 19:40 Sergio Santiago

    Although a counter is not the best solution for this use case, you can use the operator increase.

    Increase(tempin{instance="localhost:9999"}[5m])

    This will tell you how much the counter increased in the last five minutes

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum