Prometheus: getting cumulative KwH from milliwatt samples Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Prometheus rate functions and interval selectionsHow to graph individual Summary metric instances in Prometheus?Prometheus sum get no data , can i set to default value?increase() in Prometheus sometimes doubles values: how to avoid?How to run or where to find the exact queries docs for docker monitoring in prometheusPrometheus query for sum of alerts sent out each hourHow to extract values from time series database written from Prometheus to InfluxdbGrafana: combining two queries from two prometheus exportersVariable range vector selectors in PrometheusHow should i interpret this grafana visualized prometheus histogram buckets heatmap?
Lights are flickering on and off after accidentally bumping into light switch
How to get a single big right brace?
Can a Knight grant Knighthood to another?
How to ask rejected full-time candidates to apply to teach individual courses?
A German immigrant ancestor has a "Registration Affidavit of Alien Enemy" on file. What does that mean exactly?
When does Bran Stark remember Jamie pushing him?
Are Flameskulls resistant to magical piercing damage?
Does Prince Arnaud cause someone holding the Princess to lose?
Why does BitLocker not use RSA?
Why isn't everyone flabbergasted about Bran's "gift"?
What is the evidence that custom checks in Northern Ireland are going to result in violence?
Can 'non' with gerundive mean both lack of obligation and negative obligation?
Can I take recommendation from someone I met at a conference?
Is "ein Herz wie das meine" an antiquated or colloquial use of the possesive pronoun?
How to create a command for the "strange m" symbol in latex?
How to mute a string and play another at the same time
What kind of capacitor is this in the image?
tabularx column has extra padding at right?
2 sample t test for sample sizes - 30,000 and 150,000
Assertions In A Mock Callout Test
Are bags of holding fireproof?
Why did Bronn offer to be Tyrion Lannister's champion in trial by combat?
Why do C and C++ allow the expression (int) + 4*5?
When speaking, how do you change your mind mid-sentence?
Prometheus: getting cumulative KwH from milliwatt samples
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Prometheus rate functions and interval selectionsHow to graph individual Summary metric instances in Prometheus?Prometheus sum get no data , can i set to default value?increase() in Prometheus sometimes doubles values: how to avoid?How to run or where to find the exact queries docs for docker monitoring in prometheusPrometheus query for sum of alerts sent out each hourHow to extract values from time series database written from Prometheus to InfluxdbGrafana: combining two queries from two prometheus exportersVariable range vector selectors in PrometheusHow should i interpret this grafana visualized prometheus histogram buckets heatmap?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have an energy monitoring device, a Belkin Wemo, that reports current usage in milliwatts, and I have those being exported into prometheus. What I'd like is a graph that shows me cumulative KwH, monotonically increasing, since the moment I started collecting data.
The following query plotted in a table with a min_step=1h shows me KwH for each hour, and they add up to what I believe the total KwH is, so I'm pretty sure my data is correct:
sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h])
Plotting that same query in a graph does not do what I want, because I want a cumulative total, not a series of individual hourly totals. If I could just sum the results of this query, I think it would do what I want. However, the sum() operator just doesn't seem to do what I think it would when wrapped around the above query.
add a comment |
I have an energy monitoring device, a Belkin Wemo, that reports current usage in milliwatts, and I have those being exported into prometheus. What I'd like is a graph that shows me cumulative KwH, monotonically increasing, since the moment I started collecting data.
The following query plotted in a table with a min_step=1h shows me KwH for each hour, and they add up to what I believe the total KwH is, so I'm pretty sure my data is correct:
sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h])
Plotting that same query in a graph does not do what I want, because I want a cumulative total, not a series of individual hourly totals. If I could just sum the results of this query, I think it would do what I want. However, the sum() operator just doesn't seem to do what I think it would when wrapped around the above query.
add a comment |
I have an energy monitoring device, a Belkin Wemo, that reports current usage in milliwatts, and I have those being exported into prometheus. What I'd like is a graph that shows me cumulative KwH, monotonically increasing, since the moment I started collecting data.
The following query plotted in a table with a min_step=1h shows me KwH for each hour, and they add up to what I believe the total KwH is, so I'm pretty sure my data is correct:
sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h])
Plotting that same query in a graph does not do what I want, because I want a cumulative total, not a series of individual hourly totals. If I could just sum the results of this query, I think it would do what I want. However, the sum() operator just doesn't seem to do what I think it would when wrapped around the above query.
I have an energy monitoring device, a Belkin Wemo, that reports current usage in milliwatts, and I have those being exported into prometheus. What I'd like is a graph that shows me cumulative KwH, monotonically increasing, since the moment I started collecting data.
The following query plotted in a table with a min_step=1h shows me KwH for each hour, and they add up to what I believe the total KwH is, so I'm pretty sure my data is correct:
sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h])
Plotting that same query in a graph does not do what I want, because I want a cumulative total, not a series of individual hourly totals. If I could just sum the results of this query, I think it would do what I want. However, the sum() operator just doesn't seem to do what I think it would when wrapped around the above query.
asked Mar 9 at 2:22
smbakersmbaker
136
136
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
sum_over_time sums up the metric within the timeframe you define for it (the bit in the square brackets)
getting a commulative number from a gauge / histogram is technically impossible unless you are going to keep your data around forever, which is technically impossible :)
to properly get what you want, you are going to need to turn this from a gauge / histogram metric into an increment metric
add a comment |
I think I came up with a workable solution, using Prometheus subqueries. I believe I had to upgrade my version of Prometheus to get the subquery support. With subqueries, it's possible to compute the Kilowatt-Hours and then sum them up. I started with this:
sum_over_time( (sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h]))[1y:1h] )
Then I wanted higher resolution (the above will lag a bit), so I reduced the intervals down to 5 minutes:
sum_over_time( (sum_over_time(current_power[5m])/1000/1000/count_over_time(current_power[5m]))[1y:5m] )/12
This gives me KwH for the last year. I've only tested it for a day and a half.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073399%2fprometheus-getting-cumulative-kwh-from-milliwatt-samples%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
sum_over_time sums up the metric within the timeframe you define for it (the bit in the square brackets)
getting a commulative number from a gauge / histogram is technically impossible unless you are going to keep your data around forever, which is technically impossible :)
to properly get what you want, you are going to need to turn this from a gauge / histogram metric into an increment metric
add a comment |
sum_over_time sums up the metric within the timeframe you define for it (the bit in the square brackets)
getting a commulative number from a gauge / histogram is technically impossible unless you are going to keep your data around forever, which is technically impossible :)
to properly get what you want, you are going to need to turn this from a gauge / histogram metric into an increment metric
add a comment |
sum_over_time sums up the metric within the timeframe you define for it (the bit in the square brackets)
getting a commulative number from a gauge / histogram is technically impossible unless you are going to keep your data around forever, which is technically impossible :)
to properly get what you want, you are going to need to turn this from a gauge / histogram metric into an increment metric
sum_over_time sums up the metric within the timeframe you define for it (the bit in the square brackets)
getting a commulative number from a gauge / histogram is technically impossible unless you are going to keep your data around forever, which is technically impossible :)
to properly get what you want, you are going to need to turn this from a gauge / histogram metric into an increment metric
answered Mar 9 at 21:22
Elad AmitElad Amit
18116
18116
add a comment |
add a comment |
I think I came up with a workable solution, using Prometheus subqueries. I believe I had to upgrade my version of Prometheus to get the subquery support. With subqueries, it's possible to compute the Kilowatt-Hours and then sum them up. I started with this:
sum_over_time( (sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h]))[1y:1h] )
Then I wanted higher resolution (the above will lag a bit), so I reduced the intervals down to 5 minutes:
sum_over_time( (sum_over_time(current_power[5m])/1000/1000/count_over_time(current_power[5m]))[1y:5m] )/12
This gives me KwH for the last year. I've only tested it for a day and a half.
add a comment |
I think I came up with a workable solution, using Prometheus subqueries. I believe I had to upgrade my version of Prometheus to get the subquery support. With subqueries, it's possible to compute the Kilowatt-Hours and then sum them up. I started with this:
sum_over_time( (sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h]))[1y:1h] )
Then I wanted higher resolution (the above will lag a bit), so I reduced the intervals down to 5 minutes:
sum_over_time( (sum_over_time(current_power[5m])/1000/1000/count_over_time(current_power[5m]))[1y:5m] )/12
This gives me KwH for the last year. I've only tested it for a day and a half.
add a comment |
I think I came up with a workable solution, using Prometheus subqueries. I believe I had to upgrade my version of Prometheus to get the subquery support. With subqueries, it's possible to compute the Kilowatt-Hours and then sum them up. I started with this:
sum_over_time( (sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h]))[1y:1h] )
Then I wanted higher resolution (the above will lag a bit), so I reduced the intervals down to 5 minutes:
sum_over_time( (sum_over_time(current_power[5m])/1000/1000/count_over_time(current_power[5m]))[1y:5m] )/12
This gives me KwH for the last year. I've only tested it for a day and a half.
I think I came up with a workable solution, using Prometheus subqueries. I believe I had to upgrade my version of Prometheus to get the subquery support. With subqueries, it's possible to compute the Kilowatt-Hours and then sum them up. I started with this:
sum_over_time( (sum_over_time(current_power[1h])/1000/1000/count_over_time(current_power[1h]))[1y:1h] )
Then I wanted higher resolution (the above will lag a bit), so I reduced the intervals down to 5 minutes:
sum_over_time( (sum_over_time(current_power[5m])/1000/1000/count_over_time(current_power[5m]))[1y:5m] )/12
This gives me KwH for the last year. I've only tested it for a day and a half.
answered Mar 10 at 1:19
smbakersmbaker
136
136
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073399%2fprometheus-getting-cumulative-kwh-from-milliwatt-samples%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown