jmxtrans in kubernetes - adding ip/hostname of pod in output message

39 views
Skip to first unread message

Ritam Banik

unread,
Nov 17, 2019, 11:16:25 PM11/17/19
to jmxtrans
Hi,

I'm running jmxTrans as a sidecar alongisde my app in the same pod. I've multiple pods. My jmxTrans query json looks like,

{
      "servers" : [ {
        "port" : "5555",
        "host" : "127.0.0.1",
        "queries" : [
          {
            "obj" : "java.lang:type=Memory",
              "resultAlias":"jvmMemory",
            "outputWriters" : [
              {
                "@class" : "com.googlecode.jmxtrans.model.output.kafka.KafkaWriter",
                "rootPrefix": "jvmMemory",
                "booleanAsNumber" : false,
                "debug" : false,
                "tags" : {
                   "application": "kafka-connect",
                   "region": "lab",
                   "cluster": "connect-generic"
                },
                "settings" : {
                   "topics" : "metrics_kafka_connect",
                   "bootstrap.servers" : "brokerIP:9092"
                }
              }
            ]
           },
        "numQueryThreads" : 8
      } ]
    }

A message exported by the Kafka writer into a topic looks like,

{
  "keyspace": "SourceTaskMetrics.127_0_0_1_5555.SourceTaskMetrics.export-db-ut-calldata-1_0.source-record-poll-rate",
  "value": "0.0",
  "timestamp": 1573075690,
  "tags": {
    "application": "kafka-connect",
    "region": "lab",
    "cluster": "generic"
  }

I need to add the pod IP/hostname in the message. Since, running in container needs to have the host as 127.0.0.1 in the query file, so how do I add this info in the query file? Is there a way in the query file to read the pod environment info?

Thanks,
Ritam
Reply all
Reply to author
Forward
0 new messages