-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update kubernetes_state to use the new OpenMetricsBaseCheck #1983
Conversation
e7b150c
to
55edc20
Compare
bdd07ff
to
620a065
Compare
|
||
# run check twice to have pod/node mapping | ||
for _ in range(2): | ||
check.check(instance) | ||
print('HEREBRUH') | ||
for i in aggregator._metrics.items(): | ||
print i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a debugging block 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, I thought I caught all my print
s.
b3180b7
to
579904a
Compare
ac8ce72
to
00f8cca
Compare
be99352
to
d5b1cdb
Compare
b19a23e
to
e66cd28
Compare
222cee3
to
7bde919
Compare
e66cd28
to
458fbbe
Compare
458fbbe
to
03297b6
Compare
75ad33b
to
07fc84d
Compare
07fc84d
to
27ab390
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed common logic, will do a second pass on the magic methods
self.service_check(sc_name, mapping[label.value], tags=tags) | ||
else: | ||
self.log.debug("Unable to handle %s - unknown condition %s" % (sc_name, label.value)) | ||
if 'condition' in sample[self.SAMPLE_LABELS]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a bit repetitive, wdyt about starting with
condition = sample[self.SAMPLE_LABELS].get('condition')
if condition:
to remove these duplicate lookups?
label_value = self._extract_label_value('status', labels) | ||
return label_value, switch.get(self._extract_label_value('condition', labels), | ||
{'service_check_name': None, 'mapping': None}) | ||
return labels['status'], switch.get(labels['condition'], {'service_check_name': None, 'mapping': None}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned we might start throwing KeyError
s if the label were to miss. Shall we use get('condition')
instead, to mimic _extract_label_value
's return-None-if-not-found behaviour?
0c77454
to
7717f3b
Compare
7717f3b
to
347ba60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚤
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚤
""" | ||
Set up the kubernetes_state instance so it can be used in OpenMetricsBaseCheck | ||
""" | ||
endpoint = instance.get('kube_state_url') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1381cd9
to
8232c4a
Compare
PR feedback and remove unused fixture Use PrometheusCheck defaults Do not modify original instance Add label_to_hostname_suffix
8232c4a
to
ca02ead
Compare
PR feedback and remove unused fixture Use PrometheusCheck defaults Do not modify original instance Add label_to_hostname_suffix
What does this PR do?
Updates kubernetes_state to use the new OpenMetricsBaseCheck class.
Motivation
This fixes the check for when we use the new OpenMetricsBaseCheck class.
Review checklist
no-changelog
label attachedAdditional Notes