How to Send Data through Logstash or Kafka from Elastic APM | Elastic Blog
エンジニアリング

Elastic APMからLogstashまたはKafkaを通してデータを送信するには

寿VM使

6.4.0APMLogstashKafkaLogstash使Logstash1使APM

Elasticsearch

  1. ElasticsearchLogstash
  2. Elastic APMLogstash
  3. Elasticsearch
  4. Kafka

Logstash

beats/lumberjack使LogstashAPMElasticsearch

input {
   beats {
        id => "apm-server"
        port => 5044
  }
}
output {
  elasticsearch {
    hosts => ["elasticsearch:9200"]
    index => "apm-%{[beat][version]}-%{[processor][event]}-%{+YYYY.MM.dd}"
  }
}

111APM

beat APMBeats Framework BeatLogstashAPM[@metadata][beat] == "apm-server"使

APM

LogstashAPMapm-server.yml

output.elasticsearch:
  enabled: false
output.logstash
  enabled: true
  hosts: ["logstash:5044"]

backoffproxysslElastic APM

APM

xpack.monitoring.elasticsearch:
  enabled: true
  hosts: ["elasticsearch:9200"]

APMElasticsearch

Elasticsearch

APM1 ElasticsearchAPM UIAPM 2

ElasticsearchAPM

 apm-server setup --template

APM

apm-server export template > apm-6.4.2.tmpl.json

Elasticsearch curl使

curl -XPUT -H 'Content-Type: application/json' http://elasticsearch:9200/_template/apm-6.4.2 -d @apm-6.4.2.tmpl.json

_template/apm-*

{
  "apm-6.4.2": {
    "order":1,
    "index_patterns": [
      "apm-6.4.2-*"
    ],
...

Logstash

1.LogstashAPM 1.APM

使

APM

使 Javascript使

APMElasticsearch ElasticsearchAPM使 rum.source_mapping.elasticsearch

apm-server:
  rum:
    source_mapping:
      elasticsearch:
        hosts: ["elasticsearch:9200"]
        index_pattern: "apm-*-sourcemap*"

APMapm-*-sourcemap*

LogstashElasticsearch Logstash使

Kafka

KafkaAPMElasticsearch使 Kafka使APM

output.kafka:
  enabled: true
  hosts: ["kafka:9092"]
  topics:
    - default: 'apm'
      topic: 'apm-%{[context.service.name]}'

11使

KafkaElasticsearchLogstash

input {
  kafka {
    id => "apm-server-kafka"
    bootstrap_servers => ["kafka:9092"]
    topics_pattern => "apm.*"
    codec => "json"
  }
}
output {
  elasticsearch {
    hosts => ["elasticsearch:9200"]
    index => "apm-%{[beat][version]}-%{[processor][event]}-%{+YYYY.MM.dd}"
  }
}

111APM Logstash Kafka

Give it a try

APMLogstashKafka使APM