如何使用logstash将jolokia响应解析为Elasticsearch

时间:2016-01-23 22:45:33

标签: logstash logstash-logback-encoder

我正在尝试创建一个轮询ActiveMQ jolokia端点的logstash管道。我想收集代理队列的所有指标。我有以下管道。

input {
  http_poller {
    urls => {
      health_metrics => {
        method => "get"
        url => "http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,destinationType=Queue,destinationName=*"
        headers => {
          "Content-Type" => "application/json"
        }
        auth => {
          user => "admin"
          password => "admin"
        }       
      }
    }
    request_timeout => 30
    keepalive => false
    interval => 5
    codec => "json"
    type => "activemq_broker_queue"
  }
}

filter {  
    json_encode {
      source => "value"
    }
    json {
      source => "value"
    }
    mutate {
      remove_field => ["request", "value", "timestamp"]
    }

}

output {
  elasticsearch {
    hosts => "localhost"
    # An index is created for each type of metrics inpout
    index => "logstash-activmq" 
    document_type => "%{type}" 
  }
   stdout {
    codec => rubydebug
  }
}

我的jolokia响应采用这种格式。

{
    request: {
        mbean: "org.apache.activemq:brokerName=localhost,destinationName=*,destinationType=Queue,type=Broker",
        type: "read"
    },
    value: {
        org.apache.activemq: brokerName=localhost,
        destinationName=SEARCH,
        destinationType=Queue,
        type=Broker: {
            ProducerFlowControl: true,
            Options: "",
            AlwaysRetroactive: false,
            MemoryUsageByteCount: 0,
            AverageBlockedTime: 0,
            MemoryPercentUsage: 0,
            CursorMemoryUsage: 0,
            InFlightCount: 0,
            Subscriptions: [],
            CacheEnabled: true,
            ForwardCount: 0,
            DLQ: false,
            StoreMessageSize: 0,
            AverageEnqueueTime: 0,
            Name: "SEARCH",
            BlockedSends: 0,
            TotalBlockedTime: 0,
            MaxAuditDepth: 2048,
            QueueSize: 0,
            MaxPageSize: 200,
            PrioritizedMessages: false,
            MemoryUsagePortion: 1,
            Paused: false,
            EnqueueCount: 0,
            MessageGroups: {

            },
            ConsumerCount: 0,
            AverageMessageSize: 0,
            CursorFull: false,
            ExpiredCount: 0,
            MaxProducersToAudit: 1024,
            CursorPercentUsage: 0,
            MinEnqueueTime: 0,
            MemoryLimit: 668309914,
            MinMessageSize: 0,
            DispatchCount: 0,
            MaxEnqueueTime: 0,
            DequeueCount: 0,
            BlockedProducerWarningInterval: 30000,
            ProducerCount: 0,
            MessageGroupType: "cached",
            MaxMessageSize: 0,
            UseCache: true,
            SlowConsumerStrategy: null
        },
        org.apache.activemq: brokerName=localhost,
        destinationName=weather,
        destinationType=Queue,
        type=Broker: {
            ProducerFlowControl: true,
            Options: "",
            AlwaysRetroactive: false,
            MemoryUsageByteCount: 0,
            AverageBlockedTime: 0,
            MemoryPercentUsage: 0,
            CursorMemoryUsage: 0,
            InFlightCount: 0,
            Subscriptions: [],
            CacheEnabled: true,
            ForwardCount: 0,
            DLQ: false,
            StoreMessageSize: 0,
            AverageEnqueueTime: 0,
            Name: "weather",
            BlockedSends: 0,
            TotalBlockedTime: 0,
            MaxAuditDepth: 2048,
            QueueSize: 0,
            MaxPageSize: 200,
            PrioritizedMessages: false,
            MemoryUsagePortion: 1,
            Paused: false,
            EnqueueCount: 0,
            MessageGroups: {

            },
            ConsumerCount: 0,
            AverageMessageSize: 0,
            CursorFull: false,
            ExpiredCount: 0,
            MaxProducersToAudit: 1024,
            CursorPercentUsage: 0,
            MinEnqueueTime: 0,
            MemoryLimit: 668309914,
            MinMessageSize: 0,
            DispatchCount: 0,
            MaxEnqueueTime: 0,
            DequeueCount: 0,
            BlockedProducerWarningInterval: 30000,
            ProducerCount: 0,
            MessageGroupType: "cached",
            MaxMessageSize: 0,
            UseCache: true,
            SlowConsumerStrategy: null
        }
    },
    timestamp: 1453588727,
    status: 200
}

我希望能够将两个队列目标分成两个不同的文档,然后将它们保存到ES。

目前,我收到的错误信息不包含'。'

0 个答案:

没有答案