Skip to content

Commit

Permalink
migrate to ECS
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin committed Jan 29, 2019
1 parent 67d4fba commit e4ae0a3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 26 deletions.
4 changes: 2 additions & 2 deletions metricbeat/module/php_fpm/pool/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"php_fpm": {
"pool": {
"connections": {
"accepted": 5,
"accepted": 10,
"listen_queue_len": 0,
"max_listen_queue": 0,
"queued": 0
Expand All @@ -30,7 +30,7 @@
"total": 2
},
"slow_requests": 0,
"start_since": 57,
"start_since": 491,
"start_time": 1548678234
}
},
Expand Down
32 changes: 23 additions & 9 deletions metricbeat/module/php_fpm/process/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
"duration": 115000,
"module": "php_fpm"
},
"http": {
"request": {
"method": "GET"
},
"response": {
"body": {
"bytes": 0
}
}
},
"metricset": {
"name": "process"
},
Expand All @@ -17,23 +27,27 @@
"name": "www"
},
"process": {
"content_length": 0,
"last_request_cpu": 0,
"last_request_memory": 0,
"pid": 27,
"request_duration": 133,
"request_method": "GET",
"request_uri": "/status?full=\u0026json=",
"requests": 4,
"request_duration": 231,
"requests": 6,
"script": "-",
"start_since": 59,
"start_since": 492,
"start_time": 1548678234,
"state": "Running",
"user": "-"
"state": "Running"
}
},
"process": {
"pid": 27
},
"service": {
"address": "127.0.0.1:81",
"type": "php_fpm"
},
"url": {
"original": "/status?full=\u0026json="
},
"user": {
"name": "-"
}
}
48 changes: 33 additions & 15 deletions metricbeat/module/php_fpm/process/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,40 @@ func eventsMapping(r mb.ReporterV2, content []byte) {
}
//remapping process details to match the naming format
for _, process := range status.Processes {
proc := common.MapStr{
"pid": process.PID,
"state": process.State,
"start_time": process.StartTime,
"start_since": process.StartSince,
"requests": process.Requests,
"request_duration": process.RequestDuration,
"request_method": process.RequestMethod,
"request_uri": process.RequestURI,
"content_length": process.ContentLength,
"user": process.User,
"script": process.Script,
"last_request_cpu": process.LastRequestCPU,
"last_request_memory": process.LastRequestMemory,
event := mb.Event{
RootFields: common.MapStr{
"http": common.MapStr{
"request": common.MapStr{
"method": process.RequestMethod,
},
"response": common.MapStr{
"body": common.MapStr{
"bytes": process.ContentLength,
},
},
},
"user": common.MapStr{
"name": process.User,
},
"process": common.MapStr{
"pid": process.PID,
},
"url": common.MapStr{
"original": process.RequestURI,
},
},
MetricSetFields: common.MapStr{
"state": process.State,
"start_time": process.StartTime,
"start_since": process.StartSince,
"requests": process.Requests,
"request_duration": process.RequestDuration,
"script": process.Script,
"last_request_cpu": process.LastRequestCPU,
"last_request_memory": process.LastRequestMemory,
},
}
event := mb.Event{MetricSetFields: proc}

event.ModuleFields = common.MapStr{}
event.ModuleFields.Put("pool.name", status.Name)
r.Event(event)
Expand Down

0 comments on commit e4ae0a3

Please sign in to comment.