-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use scrapeconfig instead of servicemonitor (#607)
* Move from ServiceMonitor to ScrapeConfig * Clean up legacy servicemonitors * Emulate servicemonitor-compatible labels * Update roles/servicetelemetry/tasks/component_scrapeconfig.yml Co-authored-by: Jaromír Wysoglad <[email protected]>
- Loading branch information
Showing
9 changed files
with
117 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
- name: Look up prometheus-stf SA to get auth secret name | ||
k8s_info: | ||
api_version: v1 | ||
kind: ServiceAccount | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
name: prometheus-stf | ||
register: service_account | ||
|
||
- name: Look up auth secret to get token secret name | ||
k8s_info: | ||
api_version: v1 | ||
kind: Secret | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
name: '{{ service_account.resources[0].secrets[0].name }}' | ||
register: auth_secret | ||
|
||
- name: Create SG-specific Scrape Config manifest | ||
set_fact: | ||
sg_specific_scrapeconfig_manifest: | | ||
apiVersion: {{ prometheus_operator_api_string | replace("/v1","/v1alpha1") }} | ||
kind: ScrapeConfig | ||
metadata: | ||
labels: | ||
app: smart-gateway | ||
name: '{{ this_smartgateway }}' | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
spec: | ||
authorization: | ||
type: bearer | ||
credentials: | ||
name: '{{ auth_secret.resources[0].metadata.annotations['openshift.io/token-secret.name'] }}' | ||
key: token | ||
metricRelabelings: | ||
- action: labeldrop | ||
regex: pod | ||
- action: labeldrop | ||
regex: namespace | ||
- action: labeldrop | ||
regex: instance | ||
- action: replace | ||
regex: '.*/(.*)$' | ||
replacement: $1 | ||
sourceLabels: [job] | ||
targetLabel: service | ||
- action: labeldrop | ||
regex: job | ||
- action: labeldrop | ||
regex: publisher | ||
- action: replace | ||
targetLabel: container | ||
replacement: sg-core | ||
- action: replace | ||
targetLabel: endpoint | ||
replacement: prom-https | ||
scheme: HTTPS | ||
scrapeInterval: {{ servicetelemetry_vars.backends.metrics.prometheus.scrape_interval }} | ||
staticConfigs: | ||
- targets: | ||
- '{{ this_smartgateway }}.{{ ansible_operator_meta.namespace }}.svc:8083' | ||
tlsConfig: | ||
ca: | ||
configMap: | ||
name: serving-certs-ca-bundle | ||
key: service-ca.crt | ||
serverName: '{{ this_smartgateway }}.{{ ansible_operator_meta.namespace }}.svc' | ||
- name: Create ScrapeConfig to scrape Smart Gateway | ||
k8s: | ||
state: '{{ "present" if servicetelemetry_vars.backends.metrics.prometheus.enabled else "absent" }}' | ||
definition: | ||
'{{ sg_specific_scrapeconfig_manifest }}' | ||
|
||
- name: Create additional ScrapeConfig if provided | ||
k8s: | ||
state: '{{ "present" if servicetelemetry_vars.backends.metrics.prometheus.enabled else "absent" }}' | ||
definition: | ||
'{{ scrapeconfig_manifest }}' | ||
when: scrapeconfig_manifest is defined | ||
|
||
- name: Create additional ServiceMonitor if provided (legacy) | ||
k8s: | ||
state: '{{ "present" if servicetelemetry_vars.backends.metrics.prometheus.enabled else "absent" }}' | ||
definition: | ||
'{{ servicemonitor_manifest }}' | ||
when: servicemonitor_manifest is defined | ||
|
||
- name: Remove (legacy) default ServiceMonitors | ||
k8s: | ||
state: absent | ||
api_version: '{{ prometheus_operator_api_string }}' | ||
kind: ServiceMonitor | ||
namespace: '{{ ansible_operator_meta.namespace }}' | ||
name: '{{ this_smartgateway }}' |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters