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

KeyError: 'services' in metrics collector #4455

Closed
zeeZ opened this issue Jun 4, 2024 · 1 comment
Closed

KeyError: 'services' in metrics collector #4455

zeeZ opened this issue Jun 4, 2024 · 1 comment
Assignees
Labels
bug Something isn't working part:metrics/logging Relate to metric exporting or logging

Comments

@zeeZ
Copy link

zeeZ commented Jun 4, 2024

What went wrong?

What happened:

Metrics endpoint at /metrics/ returns 500 internal server error:

2024-06-04 08:16:20 source=engine:app google_trace_id=none logger=django.request Internal Server Error: /metrics/
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/app/apps/metrics_exporter/views.py", line 22, in get
    result = generate_latest(application_metrics_registry).decode("utf-8")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/exposition.py", line 198, in generate_latest
    for metric in registry.collect():
  File "/usr/local/lib/python3.11/site-packages/prometheus_client/registry.py", line 97, in collect
    yield from collector.collect()
  File "/etc/app/apps/metrics_exporter/metrics_collectors.py", line 65, in collect
    alert_groups_total, missing_org_ids_1 = self._get_alert_groups_total_metric(org_ids)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/app/apps/metrics_exporter/metrics_collectors.py", line 104, in _get_alert_groups_total_metric
    for service_name in integration_data["services"]:
                        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'services'

How do we reproduce it?

Unable to reproduce in dev, but this change removed two checks in old lines 104 and 150: https://github.com/grafana/oncall/pull/4300/files#diff-f52a4f487bce825b13cf5540d5c960096703b3cfb73815791bb77fe1c55778d1L104

Grafana OnCall Version

1.5.4, 1.6.0

Product Area

Other

Grafana OnCall Platform?

Docker

User's Browser?

No response

Anything else to add?

Upgraded from 1.3.117 with working metrics to 1.5.4 and then 1.6.0, both versions returning 500

@zeeZ zeeZ added the bug Something isn't working label Jun 4, 2024
@joeyorlando joeyorlando added part:metrics/logging Relate to metric exporting or logging and removed needs triage more info needed labels Jun 13, 2024
@Ferril Ferril self-assigned this Jul 17, 2024
@Ferril Ferril mentioned this issue Jul 17, 2024
3 tasks
github-merge-queue bot pushed a commit that referenced this issue Jul 17, 2024
# What this PR does
based on this PR - #4517

## Which issue(s) this PR closes

Related to #4455

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.
@joeyorlando
Copy link
Contributor

@Ferril can this be closed now that #4695 is merged?

@Ferril Ferril closed this as completed Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working part:metrics/logging Relate to metric exporting or logging
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants