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

How to get jmx metrics in prometheus-kubernetes project? #91

Open
andrvin opened this issue Jun 21, 2018 · 3 comments
Open

How to get jmx metrics in prometheus-kubernetes project? #91

andrvin opened this issue Jun 21, 2018 · 3 comments

Comments

@andrvin
Copy link

andrvin commented Jun 21, 2018

Hi guys! Thank you for your job!
Everything is good, but I just don't know how to get metrics from prometheus jmx exporter agent.
The agent is installed in app container and listen on 9090 port:

spec:
      containers:
      - image: registry/image:version
        imagePullPolicy: Always
        name: app-name
        env:
        - name: JAVA_CUSTOM_OPTS
          value: "-Xms256m -Xmx512m -javaagent:./jmx_prometheus_javaagent.jar=9090:jmx/prom-jmx-agent-config.yml"
        ports:
        - name: app
          containerPort: 8080
        - name: monitoring
          containerPort: 9090 

How I can add this new target into prometheus configuration? Usually I just have to edit prometheus.yml config file, but I don't understand how to add it into your configuration.

@camilb
Copy link
Owner

camilb commented Jun 29, 2018

Hi @andrvin this should work, you have to replace the selector label and the namespace.

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: jmx
  namespace: monitoring
  labels:
    k8s-app: jmx
spec:
  selector:
    matchLabels:
      your_label_key: your_label_value
  endpoints:
  - port: monitoring
    interval: 10s
  namespaceSelector:
    matchNames:
    - your_app_namespace

Save it to a file and kubectl create -f file.yaml

@dberardo-com
Copy link

how does the attribute "port" work in prometheus ? i cant use integers there, so what is the convention being used ?

@camilb
Copy link
Owner

camilb commented Nov 15, 2022

@dberardo-com You can see an example here. The port should match the service port name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants