Hi, trying to scrape metrics on prometheus, gettin...
# troubleshooting
s
Hi, trying to scrape metrics on prometheus, getting error
expected a valid start token, got "[" ("INVALID") while parsing: "["
On checking
<http://localhost:8081/jobmanager/metrics>
getting below metrics, any idea why not able to get metrics
Copy code
[{"id":"Status.JVM.GarbageCollector.PS_MarkSweep.Time"},{"id":"Status.JVM.Memory.Mapped.TotalCapacity"},{"id":"taskSlotsAvailable"},{"id":"taskSlotsTotal"},{"id":"Status.JVM.Memory.Mapped.MemoryUsed"},{"id":"Status.JVM.CPU.Time"},{"id":"Status.JVM.Threads.Count"},{"id":"Status.JVM.Memory.Heap.Committed"},{"id":"Status.JVM.Memory.Metaspace.Committed"},{"id":"Status.JVM.GarbageCollector.PS_MarkSweep.Count"},{"id":"Status.JVM.GarbageCollector.PS_Scavenge.Time"},{"id":"Status.JVM.Memory.Direct.Count"},{"id":"Status.JVM.GarbageCollector.PS_Scavenge.Count"},{"id":"Status.JVM.Memory.NonHeap.Max"},{"id":"numRegisteredTaskManagers"},{"id":"Status.JVM.Memory.NonHeap.Committed"},{"id":"Status.JVM.Memory.NonHeap.Used"},{"id":"Status.JVM.Memory.Metaspace.Max"},{"id":"Status.JVM.Memory.Direct.MemoryUsed"},{"id":"Status.JVM.Memory.Direct.TotalCapacity"},{"id":"numRunningJobs"},{"id":"Status.JVM.ClassLoader.ClassesLoaded"},{"id":"Status.JVM.Memory.Mapped.Count"},{"id":"Status.JVM.Memory.Metaspace.Used"},{"id":"Status.JVM.CPU.Load"},{"id":"Status.JVM.Memory.Heap.Max"},{"id":"Status.JVM.Memory.Heap.Used"},{"id":"Status.JVM.ClassLoader.ClassesUnloaded"}]
Also added below in flink-conf.yaml
Copy code
metrics.reporters: prom
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
k
You also need to add factory class as bellow
Copy code
metrics.reporters: prom
metrics.reporter.prom.class: org.apache.flink.metrics.prometheus.PrometheusReporter
metrics.reporter.prom.factory.class: org.apache.flink.metrics.prometheus.PrometheusReporterFactory
s
thanks @Krutik Gadhiya, as suggested added factory class as well, but still getting the same error. Below is default prometheus.yml, whats wrong in this any idea ?
Copy code
# my global config
global:
  scrape_interval: 15s
  evaluation_interval: 15s
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
#  - job_name: "prometheus"

# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.

scrape_configs:
  - job_name: "flink"
    metrics_path: /jobmanager/metrics
    static_configs:
      - targets:
        - "localhost:8081"
        - "taskmanager1:8081"
        - "taskmanager2:8081"
k
try without
metrics_path
s
I guess, metrics_path needs to be defined
k
are propetheus and flink running in same environment?
s
yes, for now i am testing on my mac
on Prod, both are running in different EC2, but its configured to scrape data from all EC2s
k
metrics_path has default value as /metrics
also you need to add
metrics.reporter.prom.port: port
to your flink-config.yml
s
Default port is 8081
k
i think you need to give a port or port range i am using something like this, so on the first port 9250 jobmanager's metrics would be exposed and after then each taskmanager's metrics would be available on the ports from 9251
metrics.reporter.prom.port: 9250-9260
s
Can you share prometheus.yml’s flink part as well
k
Copy code
- job_name: "flink_JobManager"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9250"]

  - job_name: 'flink_TaskManager'

    static_configs:
      - targets: ["localhost:9251"]
s
Great Bro !! Working now Thanks @Krutik Gadhiya
🙌 1
@Krutik Gadhiya What the Grafana Dashboard ID you are using ?
for me, its only showing last checkpoint duration, flink version used in 1.17