-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can the metrics_name be in the format of an expression? #240
Comments
Hi @lynBIT, thanks for opening an issue 😄 I believe it is possible, but using start_time = parse_datetime("3d")
end_time = parse_datetime("now")
query = '1 - sum(increase(node_cpu_seconds_total{mode="idle"}[5m])) by (instance) / sum(increase(node_cpu_seconds_total[5m])) by (instance)'
metric_data = pc.custom_query_range(
query,
start_time=start_time,
end_time=end_time,
step="1d",
)
metric_data
# output:
[{'metric': {'instance': 'demo.do.prometheus.io:9100'},
'values': [[1656361768, '0.06370670074256046'],
[1656448168, '0.057729768018532024'],
[1656534568, '0.06394668746362964'],
[1656620968, '0.06474131821663776']]}] Hope this helps! |
Hi @lynBIT, did the above suggestion help resolve your problem? Can this issue be closed now? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the solution you'd like
I want to get the value of the computed expression through Prometheus' API。
pc.get_metric_range_data(metric_name=train_data[0].metric_name ....)
Can I make metric_name = (1- sum(increase(node_cpu_seconds_total{mode='idle',instance='172.29.3.13:9101'}[2m])) by (instance)/sum(increase(node_cpu_seconds_total{instance='172.29.3.13:9101'}[2m])) by (instance)) *100
The calculated metrics
Additional context
The text was updated successfully, but these errors were encountered: