DataDog / dd-trace-java

Datadog APM client for Java
https://docs.datadoghq.com/tracing/languages/java
Apache License 2.0
593 stars 292 forks source link

Stream Hikaricp Pool jmx metrics to Datadog #3063

Open royremit opened 3 years ago

royremit commented 3 years ago

Hi, I'm not sure if it's the right place to post a question but I'll try it here.

We are building a docker container and using the java agent for datadog. My goal is to start sending Hikaricp pool metrics to datadog.

we start our application like this.

CMD ["/bin/sh", "-c", \
     "java -XX:MinRAMPercentage=50.0 \
     -XX:MaxRAMPercentage=80.0 \
     -javaagent:./dd-java-agent.jar \
     -Ddd.jmxfetch.config.dir=metrics \
     -Ddd.jmxfetch.config=conf.yaml \
     -jar ./apps.jar" \
 ]

Note : all the DD environment variable are injected by k8s when the container start. All the default jvm metric stream fine to datadog....

I did verify in mbean explorer in VisualVm and the metric are there!

I created a file conf.yaml like this in metrics\cong.yaml

init_config:
  is_jmx: true
  collect_default_metrics: true
  conf:
    - include:
      domain: com.zaxxer.hikari
      bean_regex:
        - com.zaxxer.hikari:type=Pool.*
      name: Pool
      attribute:
        ActiveConnections:
          metric_type: gauge
          alias: hikaricp.activeconnections
        IdleConnections:
          metric_type: gauge
          alias: hikaricp.idleconnections
        ThreadsAwaitingConnection:
          metric_type: gauge
          alias: hikaricp.threadsawaitingconnection
        TotalConnections:
          metric_type: gauge
          alias: hikaricp.totalconnections

instances:
  - host: 127.0.0.1

I don't get any error when my application start but nothing look to work....

Do I miss something important? How I could debug this to see if anything is wrong?

Thanks

royremit commented 3 years ago

I did more modification without a lot of more progress my file look like this now ;

init_config:
instances:
  - jvm_direct: true
    name: hubspot-deletion
    conf:
      - include:
        bean_regex:
          - com\.zaxxer\.hikari:type=Pool (.*
        attribute:
          ActiveConnections:
            metric_type: gauge
            alias: hikaricp.activeconnections
          IdleConnections:
            metric_type: gauge
            alias: hikaricp.idleconnections
          ThreadsAwaitingConnection:
            metric_type: gauge
            alias: hikaricp.threadsawaitingconnection
          TotalConnections:
            metric_type: gauge
            alias: hikaricp.totalconnections

still no luck.

devinsba commented 3 years ago

Sorry, I'm not sure how to help you here. You might get more support in https://github.com/DataDog/jmxfetch

bbensky commented 3 years ago

@royremit - We are trying to get the same Hikaricp Pool metrics to Datadog - were you able to find a configuration that worked?

willianccs commented 1 year ago

I need to send some metrics about Hikaricp too. It's necessary to build an custom image to aim this? I saw this documentation page, but I confused about that. Currenty we using datadog-agent-jmx image inside Kubernetes to fetch metrics about ignite, for Hikaricp this way doesn't works?

skysbsb commented 10 months ago

@royremit did u manage to fix it? how?

er1c commented 4 days ago

This worked for me:

init_config:

instances:
  - jvm_direct: true
    name: hikari-slick-monitoring
    collect_default_jvm_metrics: false
    collect_default_metrics: false
    refresh_beans: 60
    conf:
      - include:
          bean_regex: "com.zaxxer.hikari:type=Pool \\((.*)\\)"
          tags:
            pool: $1
          attribute:
            ActiveConnections:
              metric_type: gauge
              alias: hikaricp.connections.active
            IdleConnections:
              metric_type: gauge
              alias: hikaricp.connections.idle
            TotalConnections:
              metric_type: gauge
              alias: hikaricp.connections.total
            PendingThreads:
              metric_type: gauge
              alias: hikaricp.connections.pending
            MaxConnections:
              metric_type: gauge
              alias: hikaricp.connections.max
            MinConnections:
              metric_type: gauge
              alias: hikaricp.connections.min
            ConnectionAcquireMillis:
              metric_type: timer
              alias: hikaricp.connections.acquire
            ConnectionUsageMillis:
              metric_type: timer
              alias: hikaricp.connections.usage
            ConnectionTimeoutRate:
              metric_type: counter
              alias: hikaricp.connections.timeout
            ConnectionCreationMillis:
              metric_type: timer
              alias: hikaricp.connections.creation
      - include:
          bean_regex: "slick:type=AsyncExecutor,name=(.*)"
          tags:
            pool: $1
          attribute:
            MaxThreads:
              metric_type: gauge
              alias: slick.executor.threads.max
            QueueSize:
              metric_type: gauge
              alias: slick.executor.queue.size
            MaxQueueSize:
              metric_type: gauge
              alias: slick.executor.queue.max_size
            ActiveThreads:
              metric_type: gauge
              alias: slick.executor.threads.active
            TotalExecutionTime:
              metric_type: counter
              alias: slick.executor.total_execution_time
mwisnicki commented 4 days ago

@royremit

I did more modification without a lot of more progress my file look like this now ;

init_config:
instances:
  - jvm_direct: true
    name: hubspot-deletion
    conf:
      - include:
        bean_regex:
          - com\.zaxxer\.hikari:type=Pool (.*
        attribute:
          ActiveConnections:
            metric_type: gauge
            alias: hikaricp.activeconnections
          IdleConnections:
            metric_type: gauge
            alias: hikaricp.idleconnections
          ThreadsAwaitingConnection:
            metric_type: gauge
            alias: hikaricp.threadsawaitingconnection
          TotalConnections:
            metric_type: gauge
            alias: hikaricp.totalconnections

still no luck.

Add 2 spaces to everything below include line.

er1c commented 4 days ago

@royremit

I did more modification without a lot of more progress my file look like this now ;

init_config:
instances:
  - jvm_direct: true
    name: hubspot-deletion
    conf:
      - include:
        bean_regex:
          - com\.zaxxer\.hikari:type=Pool (.*
        attribute:
          ActiveConnections:
            metric_type: gauge
            alias: hikaricp.activeconnections
          IdleConnections:
            metric_type: gauge
            alias: hikaricp.idleconnections
          ThreadsAwaitingConnection:
            metric_type: gauge
            alias: hikaricp.threadsawaitingconnection
          TotalConnections:
            metric_type: gauge
            alias: hikaricp.totalconnections

still no luck.

Add 2 spaces to everything below include line.

- com\.zaxxer\.hikari:type=Pool (.* this is an incorrect regex as well you would need to escape the \( you could also create this as a string and not as an array