Skip to content
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

Domain name parse error: unexpected identifier #256

Open
rmalenko opened this issue Nov 3, 2022 · 3 comments
Open

Domain name parse error: unexpected identifier #256

rmalenko opened this issue Nov 3, 2022 · 3 comments

Comments

@rmalenko
Copy link

rmalenko commented Nov 3, 2022

I have got this error
full domain name au.edu in error message \\"au\\" i.e .edu is disappeared

File "./prometheus_query.py", line 35, in <module>
    metric_data = prom.custom_query(
  File "/usr/local/lib/python3.8/dist-packages/prometheus_api_client/prometheus_connect.py", line 355, in custom_query
    raise PrometheusApiClientException(
prometheus_api_client.exceptions.PrometheusApiClientException: HTTP Status Code 400 (b'{"status":"error","errorType":"bad_data","error":"invalid parameter \\"query\\": 1:70: parse error: unexpected identifier \\"aubg\\" in label matching, expected string"}')

my code is:

domain = "au.edu"

metric_data = prom.custom_query(
    query="avg_over_time(host_tracker_uptime_percent{job='donodeexporter', zone="f'{domain}'"}[30d])"
)
metric_df = MetricSnapshotDataFrame(metric_data)
print(metric_df.head())

If I provide domain name this code works

metric_data = prom.custom_query(
    query="avg_over_time(host_tracker_uptime_percent{job='donodeexporter', zone='au.edu'}[30d])"
)
metric_df = MetricSnapshotDataFrame(metric_data)
print(metric_df.head())
    instance             job                   zone     timestamp                                        value
0  prom.k.com  donodeexporter  au.edu 2022-11-03 11:44:08.178999808  99.921485
@psujit775
Copy link
Contributor

I believe the issue is simply a matter of quotation marks. To fix it, you should add single quotes around "f'{domain}'". Here's an example of what the corrected query should look like:

query="avg_over_time(host_tracker_uptime_percent{job='donodeexporter', zone='"f'{domain}'"' }[30d])"

Currently, the computed value of your query is:

avg_over_time(host_tracker_uptime_percent{job='donodeexporter', zone=au.edu}[30d])

But it should be:

avg_over_time(host_tracker_uptime_percent{job='donodeexporter', zone='au.edu'}[30d])

Please update your query accordingly.

@rmalenko

@rmalenko
Copy link
Author

@psujit775 thank you!

@chauhankaranraj
Copy link
Collaborator

Hi @rmalenko, was your error resolved? Could this issue be closed now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants