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

feat(mission-control): add scrape lag metrics #378

Merged
merged 3 commits into from
Feb 13, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions charts/mission-control/templates/mission-control.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/connection.schema.json
apiVersion: mission-control.flanksource.com/v1
kind: Connection
metadata:
Expand Down Expand Up @@ -27,6 +28,7 @@ spec:
name: incident-commander-postgres
key: POSTGRES_PASSWORD
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/topology.schema.json
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
Expand Down Expand Up @@ -290,6 +292,7 @@ spec:
lookup:
postgres:
- query: SELECT count(*) FROM event_queue
name: backlog
connection: "connection://{{ .Values.connectionName }}"
display:
expr: results.rows[0].count
Expand Down Expand Up @@ -340,7 +343,11 @@ spec:
selectors:
- labelSelector: app.kubernetes.io/name=apm-hub
type: API
- checks:

# Config DB
- name: Config DB
icon: config
checks:
- inline:
http:
- display: {}
Expand Down Expand Up @@ -388,6 +395,7 @@ spec:
{'name': 'Duration', 'text': r.duration_millis != null ? string(r.duration_millis) : 'N/A', 'unit': 'ms', 'headline': true},
{'name': 'Success Count', 'value': r.success_count, 'headline': true},
{'name': 'Error Count', 'value': r.error_count, 'headline': true},
yashmehrotra marked this conversation as resolved.
Show resolved Hide resolved
{'name': 'scraper_id', 'text': r.resource_id},
yashmehrotra marked this conversation as resolved.
Show resolved Hide resolved
],
}).toJSON()

Expand All @@ -396,16 +404,41 @@ spec:
SELECT * FROM (
SELECT
ROW_NUMBER() OVER (PARTITION BY c.name ORDER BY time_end DESC) AS rn, c.name, jh.status, jh.success_count,
jh.error_count, jh.duration_millis, jh.time_end
jh.error_count, jh.duration_millis, jh.time_end, jh.resource_id
FROM config_scrapers c
INNER JOIN job_history jh ON c.id::text = jh.resource_id
WHERE jh.status NOT in ('RUNNING', 'STALE', 'SKIPPED')
) AS s WHERE rn = 1
results: 1
name: ConfigScrapers
type: lookup
icon: config
name: Config DB

{{- if .Values.prometheusURL }}
forEach:
properties:
- name: 'Max consume lag (ms)'
lookup:
prometheus:
- query: 'max(histogram_quantile(1.0, rate(informer_consume_lag_bucket{scraper="$(.properties.scraper_id)"}[5m])))'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
- name: 'New items/hr'
lookup:
prometheus:
- query: 'sum(increase(scraper_added{scraper_id="$(.properties.scraper_id)"}[24h])) / 24'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
- name: 'Updated items/hr'
lookup:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: 'Max consume lag (ms)'
lookup:
prometheus:
- query: 'max(histogram_quantile(1.0, rate(informer_consume_lag_bucket{scraper="$(.properties.scraper_id)"}[5m])))'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
- name: 'New items/hr'
lookup:
prometheus:
- query: 'sum(increase(scraper_added{scraper_id="$(.properties.scraper_id)"}[24h])) / 24'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
- name: 'Updated items/hr'
lookup:
- name: Lag
headline: true
description: 'Max consume lag (ms)'
lookup:
prometheus:
- query: 'max(histogram_quantile(1.0, rate(informer_consume_lag_bucket{scraper="$(.properties.scraper_id)"}[5m])))'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
- name: 'New items/hr'
lookup:
prometheus:
- query: 'sum(increase(scraper_added{scraper_id="$(.properties.scraper_id)"}[24h])) / 24'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
- name: 'Updated items/hr'
lookup:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, the difference was description and headline right ?

prometheus:
- query: 'sum(increase(scraper_updated{scraper_id="$(.properties.scraper_id)"}[24h])) / 24'
url: {{ .Values.prometheusURL | quote}}
display:
expr: "results[?0].orValue({'value': ''}).value"
{{- end }}

properties:
- headline: true
lookup:
Expand Down
Loading