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

Add metrics_path as known hint for autodiscovery #13996

Merged
merged 2 commits into from
Oct 10, 2019

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Oct 10, 2019

This PR adds metrics_path as a known hint for autodiscovery.

This implements the suggestion of #13958

How to test

Run metricbeat as deamonset inside a k8s cluster having added the following config part for autodiscovery:

metricbeat.autodiscover:
  providers:
    - type: kubernetes
      host: ${NODE_NAME}
      hints.enabled: true

Note: run metricbeat with -e -d autodiscover to select only autodiscover related logs

Deploy a prometheus deployment:

kind: Deployment
metadata:
  name: prom-deployment
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: prometheus
  replicas: 1
  template:
    metadata:
      labels:
        app: prometheus
      annotations:
        co.elastic.metrics/module: prometheus
        co.elastic.metrics/hosts: '${data.host}:${data.port}'
        co.elastic.metrics/metrics_path: '/metrics/prometheus'
        co.elastic.metrics/period: 1m
    spec:
      containers:
      - name: prometheus
        image: prom/prometheus
        ports:
        - containerPort: 9090

Autodiscover should catch this event and include metrics_path:/metrics/prometheus in the configuration:

2019-10-10T08:16:07.148Z DEBUG [autodiscover] autodiscover/autodiscover.go:165 Got a start event: map[config:[0xc0008fcf60] host:172.17.0.34 id:e82994de-3de2-4355-afe2-0943d71ebd09.prometheus kubernetes:{"annotations":{"co":{"elastic":{"metrics/hosts":"${data.host}:${data.port}","metrics/metrics_path":"/metrics/prometheus","metrics/module":"prometheus","metrics/period":"1m"}}},"container":{"id":"be9be50a008e42f3f7e2d17edae2296ec0e5a009c3b3591ed711139f038246ea","image":"prom/prometheus","name":"prometheus","runtime":"docker"},"labels":{"app":"prometheus","pod-template-hash":"779f8d9569"},"namespace":"kube-system","node":{"name":"minikube"},"pod":{"name":"prom-deployment8-779f8d9569-6wjvx","uid":"e82994de-3de2-4355-afe2-0943d71ebd09"},"replicaset":{"name":"prom-deployment8-779f8d9569"}} meta:{"kubernetes":{"container":{"image":"prom/prometheus","name":"prometheus"},"labels":{"app":"prometheus","pod-template-hash":"779f8d9569"},"namespace":"kube-system","node":{"name":"minikube"},"pod":{"name":"prom-deployment8-779f8d9569-6wjvx","uid":"e82994de-3de2-4355-afe2-0943d71ebd09"},"replicaset":{"name":"prom-deployment8-779f8d9569"}}} port:9090 provider:958f1f51-570a-4e8d-9e13-f43503780543 start:true]
2019-10-10T08:16:07.148Z DEBUG [autodiscover] autodiscover/autodiscover.go:190 Generated config: map[enabled:true hosts:[172.17.0.34:9090] metrics_path:/metrics/prometheus metricsets:[collector] module:prometheus period:1m timeout:3s]

closes #13958

@ChrsMark ChrsMark added containers Related to containers use case [zube]: In Review Team:Integrations Label for the Integrations team autodiscovery labels Oct 10, 2019
@ChrsMark ChrsMark self-assigned this Oct 10, 2019
@ChrsMark ChrsMark requested a review from a team as a code owner October 10, 2019 08:52
Signed-off-by: chrismark <chrismarkou92@gmail.com>
Signed-off-by: chrismark <chrismarkou92@gmail.com>
@ChrsMark ChrsMark force-pushed the add_metrics_path_hint branch from 21f5e15 to 76fe5b1 Compare October 10, 2019 08:54
@ChrsMark
Copy link
Member Author

ChrsMark commented Oct 10, 2019

Should this go for 7.5? 🤔

@exekias
Copy link
Contributor

exekias commented Oct 10, 2019

I don't see why not :)

Note: I updated description to automatically close the issue when this gets merged

@ChrsMark
Copy link
Member Author

jenkins, test this again please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodiscovery containers Related to containers use case Team:Integrations Label for the Integrations team test-plan Add this PR to be manual test plan v7.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K8s autodiscovery doesn’t accept metrics_path
3 participants