Jaeger + Elastic Search: Handson
Posted by
Manish Panchmatia
on Thursday, November 14, 2019
Labels:
DevOps,
k8s,
microservice,
software
Steps
docker run --rm -it --name=elasticsearch -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:6.8.0
docker run --rm -it --link=elasticsearch --name=kibana -p 5601:5601 docker.elastic.co/kibana/kibana:6.8.0
docker run --rm -it --link=elasticsearch --name=jaeger -e SPAN_STORAGE_TYPE=elasticsearch -e ES_SERVER_URLS=http://elasticsearch:9200 -e ES_TAGS_AS_FIELDS_ALL=true -p 16686:16686 jaegertracing/all-in-one:1.12
docker run --rm --link jaeger --env JAEGER_AGENT_HOST=jaeger --env JAEGER_AGENT_PORT=6831 -p8080-8083:8080-8083 jaegertracing/example-hotrod:latest all
Create a file JSON.txt with below conntent
{
"query" : {
"match_all" : {}
}
}
curl -XGET "localhost:9200/jaeger-span-YYYY-MM-DD/_search" -H "Content-Type: application/json" -d @json.txt
curl -XGET "localhost:9200/jaeger-span-YYYY-MM-DD/_search?size=10000" -H "Content-Type: application/json" -d @json.txt
Reference:
https://medium.com/jaegertracing/jaeger-elasticsearch-and-kibana-7ecb846137b6
JSON Output:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 441,
"max_score": 1,
"hits": [
{
"_index": "jaeger-span-2019-11-12",
"_type": "span",
"_id": "mQ2cXm4BVYoOLxBFNHpP",
"_score": 1,
"_source": {
"traceID": "553c8316169ab970",
"spanID": "2cd1c33438cb79f5",
"flags": 1,
"operationName": "HTTP GET /route",
"references": [
{
"refType": "CHILD_OF",
"traceID": "553c8316169ab970",
"spanID": "44fa89467cc873aa"
}
],
"startTime": 1573545324720315,
"startTimeMillis": 1573545324720,
"duration": 53302,
"tags": [],
"tag": {
"component": "net/http",
"http@method": "GET",
"http@status_code": 200,
"http@url": "/route?dropoff=728%2C326&pickup=106%2C311",
"internal@span@format": "proto",
"span@kind": "server"
},
"logs": [
{
"timestamp": 1573545324720369,
"fields": [
{
"key": "event",
"type": "string",
"value": "HTTP request received"
},
{
"key": "level",
"type": "string",
"value": "info"
},
{
"key": "method",
"type": "string",
"value": "GET"
},
{
"key": "url",
"type": "string",
"value": "/route?dropoff=728%2C326&pickup=106%2C311"
}
]
}
],
"process": {
"serviceName": "route",
"tags": [],
"tag": {
"client-uuid": "761a24cbd892ada8",
"hostname": "367b2536b5f9",
"ip": "172.17.0.5",
"jaeger@version": "Go-2.20.0"
}
}
}
},
.....
]
}
}
Trace JSON at Kibana APM
{
"events": [
{
"@timestamp": "2018-07-30T18:53:42.281Z",
"agent": {
"name": "elastic-node",
"version": "3.14.0"
},
"parent": {
"id": "abcdef0123456789"
},
"processor": {
"event": "span",
"name": "transaction"
},
"service": {
"environment": "staging",
"name": "backendspans"
},
"span": {
"action": "query.custom",
"duration": {
"us": 141581
},
"id": "abcdef01234567",
"name": "GET /api/types",
"subtype": "postgresql",
"type": "db"
},
"timestamp": {
"us": 1532976822281000
},
"trace": {
"id": "fdedef0123456789abcdef9876543210"
},
"transaction": {
"id": "01af25874dec69dd"
}
},
.....
]
}
Reference
https://www.elastic.co/guide/en/apm/server/current/span-indices.html
docker run --rm -it --name=elasticsearch -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:6.8.0
docker run --rm -it --link=elasticsearch --name=kibana -p 5601:5601 docker.elastic.co/kibana/kibana:6.8.0
docker run --rm -it --link=elasticsearch --name=jaeger -e SPAN_STORAGE_TYPE=elasticsearch -e ES_SERVER_URLS=http://elasticsearch:9200 -e ES_TAGS_AS_FIELDS_ALL=true -p 16686:16686 jaegertracing/all-in-one:1.12
docker run --rm --link jaeger --env JAEGER_AGENT_HOST=jaeger --env JAEGER_AGENT_PORT=6831 -p8080-8083:8080-8083 jaegertracing/example-hotrod:latest all
Create a file JSON.txt with below conntent
{
"query" : {
"match_all" : {}
}
}
curl -XGET "localhost:9200/jaeger-span-YYYY-MM-DD/_search" -H "Content-Type: application/json" -d @json.txt
curl -XGET "localhost:9200/jaeger-span-YYYY-MM-DD/_search?size=10000" -H "Content-Type: application/json" -d @json.txt
Reference:
https://medium.com/jaegertracing/jaeger-elasticsearch-and-kibana-7ecb846137b6
JSON Output:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 441,
"max_score": 1,
"hits": [
{
"_index": "jaeger-span-2019-11-12",
"_type": "span",
"_id": "mQ2cXm4BVYoOLxBFNHpP",
"_score": 1,
"_source": {
"traceID": "553c8316169ab970",
"spanID": "2cd1c33438cb79f5",
"flags": 1,
"operationName": "HTTP GET /route",
"references": [
{
"refType": "CHILD_OF",
"traceID": "553c8316169ab970",
"spanID": "44fa89467cc873aa"
}
],
"startTime": 1573545324720315,
"startTimeMillis": 1573545324720,
"duration": 53302,
"tags": [],
"tag": {
"component": "net/http",
"http@method": "GET",
"http@status_code": 200,
"http@url": "/route?dropoff=728%2C326&pickup=106%2C311",
"internal@span@format": "proto",
"span@kind": "server"
},
"logs": [
{
"timestamp": 1573545324720369,
"fields": [
{
"key": "event",
"type": "string",
"value": "HTTP request received"
},
{
"key": "level",
"type": "string",
"value": "info"
},
{
"key": "method",
"type": "string",
"value": "GET"
},
{
"key": "url",
"type": "string",
"value": "/route?dropoff=728%2C326&pickup=106%2C311"
}
]
}
],
"process": {
"serviceName": "route",
"tags": [],
"tag": {
"client-uuid": "761a24cbd892ada8",
"hostname": "367b2536b5f9",
"ip": "172.17.0.5",
"jaeger@version": "Go-2.20.0"
}
}
}
},
.....
]
}
}
Trace JSON at Kibana APM
{
"events": [
{
"@timestamp": "2018-07-30T18:53:42.281Z",
"agent": {
"name": "elastic-node",
"version": "3.14.0"
},
"parent": {
"id": "abcdef0123456789"
},
"processor": {
"event": "span",
"name": "transaction"
},
"service": {
"environment": "staging",
"name": "backendspans"
},
"span": {
"action": "query.custom",
"duration": {
"us": 141581
},
"id": "abcdef01234567",
"name": "GET /api/types",
"subtype": "postgresql",
"type": "db"
},
"timestamp": {
"us": 1532976822281000
},
"trace": {
"id": "fdedef0123456789abcdef9876543210"
},
"transaction": {
"id": "01af25874dec69dd"
}
},
.....
]
}
Reference
https://www.elastic.co/guide/en/apm/server/current/span-indices.html
0 comments:
Post a Comment