Git Product home page Git Product logo

Comments (14)

JoshVanL avatar JoshVanL commented on May 27, 2024

Hi @JaeGerW2016

Can you verify that version-checker is exposing the metrics on 8080, the expected Prometheus is scrapping the metrics, and that your grafana dashboard has right selected data source.

from version-checker.

JaeGerW2016 avatar JaeGerW2016 commented on May 27, 2024

The following is my deployment which use static manifest and metrics information

root@node1:/opt# k get ep -n  monitoring -l app=version-checker
NAME              ENDPOINTS           AGE
version-checker   172.20.2.171:8080   4m5s
root@node1:/opt# curl http://172.20.2.171:8080/metrics
# HELP version_checker_is_latest_version Where the container in use is using the latest upstream registry version
# TYPE version_checker_is_latest_version gauge
version_checker_is_latest_version{container="alertmanager",current_version="v0.20.0",image="quay.io/prometheus/alertmanager",latest_version="v0.21.0",namespace="monitoring",pod="alertmanager-prom-prometheus-operator-alertmanager-0"} 0
version_checker_is_latest_version{container="autoscaler",current_version="1.6.0",image="gcr.io/google-containers/cluster-proportional-autoscaler-amd64",latest_version="1.8.1",namespace="kube-system",pod="dns-autoscaler-79599df498-cqxvx"} 0
version_checker_is_latest_version{container="cilium-agent",current_version="v1.8.2",image="docker.io/cilium/cilium",latest_version="v1.8.2",namespace="kube-system",pod="cilium-69twj"} 1

from version-checker.

JoshVanL avatar JoshVanL commented on May 27, 2024

@JaeGerW2016 It looks like it is correctly exposing the version metrics. Next try querying the Prometheus that you are trying to scrape with. It may not be configured to look at the version-checker pod/service

from version-checker.

JaeGerW2016 avatar JaeGerW2016 commented on May 27, 2024

The following is version-checker pod/service describe informatin, in deployment manifest .spec.template.spec.container use commad ["version-checker", "-a"]

root@node1:/opt# kubectl describe pod version-checker-7f45545d65-5299h -n monitoring
Name:         version-checker-7f45545d65-5299h
Namespace:    monitoring
Priority:     0
Node:         node3/192.168.2.12
Start Time:   Tue, 25 Aug 2020 08:41:01 +0000
Labels:       app=version-checker
              pod-template-hash=7f45545d65
Annotations:  enable.version-checker.io/version-checker: true
              prometheus.io/path: /metrics
              prometheus.io/port: 8080
              prometheus.io/scrape: true
...
root@node1:/opt# k describe svc version-checker -n monitoring
Name:              version-checker
Namespace:         monitoring
Labels:            app=version-checker
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"version-checker"},"name":"version-checker","namespace":"...
Selector:          app=version-checker
Type:              ClusterIP
IP:                10.244.238.181
Port:              web  8080/TCP
TargetPort:        8080/TCP
Endpoints:         172.20.2.171:8080
Session Affinity:  None
Events:            <none>


from version-checker.

JoshVanL avatar JoshVanL commented on May 27, 2024

Hi @JaeGerW2016 can you share what Prometheus configuration you are using?

Are you installing it with prometheus-operator? Have you creates a ServiceMonitor for the version-checker?

from version-checker.

JaeGerW2016 avatar JaeGerW2016 commented on May 27, 2024

I deployed version-checker and prometheus-operater in the same namespace: monitoring, and also configured the servicemonitor for version-checker.

root@node1:/opt# k get servicemonitor -n monitoring -l app=version-checker -o yaml
apiVersion: v1
items:
- apiVersion: monitoring.coreos.com/v1
  kind: ServiceMonitor
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"monitoring.coreos.com/v1","kind":"ServiceMonitor","metadata":{"annotations":{},"labels":{"app":"version-checker"},"name":"version-checker","namespace":"monitoring"},"spec":{"endpoints":[{"path":"/metrics","port":"web"}],"namespaceSelector":{"matchNames":["monitoring"]},"selector":{"matchLabels":{"app":"version-checker"}}}}
    creationTimestamp: "2020-08-25T08:41:17Z"
    generation: 1
    labels:
      app: version-checker
    name: version-checker
    namespace: monitoring
    resourceVersion: "35804818"
    selfLink: /apis/monitoring.coreos.com/v1/namespaces/monitoring/servicemonitors/version-checker
    uid: 7d2671c4-8af1-4e22-a41f-ff349ff98c04
  spec:
    endpoints:
    - path: /metrics
      port: web
    namespaceSelector:
      matchNames:
      - monitoring
    selector:
      matchLabels:
        app: version-checker
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

from version-checker.

JoshVanL avatar JoshVanL commented on May 27, 2024

Is there a Prometheus object which has a service monitor label selector for app: version-checker?

from version-checker.

JaeGerW2016 avatar JaeGerW2016 commented on May 27, 2024

My understanding is that the servicemonitor's selector.matchLabels corresponds to the labels in the service, and there are labels in version-checker's svc: app=version-checker
I don't know if my understanding of this selector is correct.

root@node1:/opt# k describe svc version-checker -n monitoring
Name:              version-checker
Namespace:         monitoring
Labels:            app=version-checker
...

from version-checker.

JoshVanL avatar JoshVanL commented on May 27, 2024

Yes, that's correct however there needs to be a Prometheus instance which has another label selector for the service monitor.

from version-checker.

JaeGerW2016 avatar JaeGerW2016 commented on May 27, 2024

Don't quite understand what you're saying about a Prometheus instance which has another label selector for the service monitor.

from version-checker.

JoshVanL avatar JoshVanL commented on May 27, 2024

For a Prometheus to scrape the version-checker, it will need to be configured to use the service monitor you have created. For example, here is a Prometheus object which will use that service montior, which is using the label app=version-checker.

apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: version-checker
  labels:
    prometheus: version-checker
    app.kubernetes.io/name: version-checker
spec:
  replicas: 1
  serviceAccountName: prometheus
  version: v2.20.1
  serviceMonitorSelector:
    matchLabels:
      app: version-checker

from version-checker.

wiardvanrij avatar wiardvanrij commented on May 27, 2024

p.s. you could always kubectl port-forward {your-prometheus-instance} 9090 and go to localhost:9090. Then go to "targets" in the menu. This gives a good indication of what is being set-up as a target and what its status is.

from version-checker.

JaeGerW2016 avatar JaeGerW2016 commented on May 27, 2024

Thank you for your patience, having already identified the cause of the problem based on your mention of.
is caused by a problem with the podMonitorSelector and serviceMonitorSelector of the prometheus instance.
The following is a partial configuration of the prometheus instance

  podMonitorSelector:
    matchLabels:
      release: prom
...
  serviceMonitorSelector:
    matchLabels:
      release: prom

Since we share a prometheus instance, we modify the serviceMonitor and deployment configuration of version-checker by adding a label:

  labels:
    app: version-checker
    release: prom

it works!
@JoshVanL

from version-checker.

JoshVanL avatar JoshVanL commented on May 27, 2024

@JaeGerW2016 Great! Glad you got is working! 😄

from version-checker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.