From 1740863ee307a1ec7ef9a96fb89cf90f4b07999c Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Wed, 10 Mar 2021 16:07:59 +0100 Subject: [PATCH] Fix type for uwsgi.status.worker.rss field (#24468) It was defined as keyword, but it is a number. Generate different data files for the different kinds of events generated by this metricset: overall, cores and workers. (cherry picked from commit a9c98e2748974fa9ac8e9b0c6e72b07167aa18b3) --- CHANGELOG.next.asciidoc | 1 + metricbeat/docs/fields.asciidoc | 2 +- metricbeat/module/uwsgi/fields.go | 2 +- .../module/uwsgi/status/_meta/data.json | 18 ++++----- .../module/uwsgi/status/_meta/data_core.json | 32 ++++++++++++++++ .../uwsgi/status/_meta/data_worker.json | 38 +++++++++++++++++++ .../module/uwsgi/status/_meta/fields.yml | 2 +- .../uwsgi/status/status_integration_test.go | 19 +++++++--- 8 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 metricbeat/module/uwsgi/status/_meta/data_core.json create mode 100644 metricbeat/module/uwsgi/status/_meta/data_worker.json diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 992447b8347..41c19a1519d 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -326,6 +326,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Unskip s3_request integration test. {pull}23887[23887] - Add system.hostfs configuration option for system module. {pull}23831[23831] - Fix GCP not able to request Cloudfunctions metrics if a region filter was set {pull}24218[24218] +- Fix type of `uwsgi.status.worker.rss` type. {pull}24468[24468] *Packetbeat* diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 21106df1b68..1fdc977f5ba 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -46301,7 +46301,7 @@ type: keyword Resident Set Size. memory currently used by a process. if always zero try `--memory-report` option of uwsgi -type: keyword +type: long -- diff --git a/metricbeat/module/uwsgi/fields.go b/metricbeat/module/uwsgi/fields.go index 70bb1fb8e63..bb06c884b1c 100644 --- a/metricbeat/module/uwsgi/fields.go +++ b/metricbeat/module/uwsgi/fields.go @@ -32,5 +32,5 @@ func init() { // AssetUwsgi returns asset data. // This is the base64 encoded gzipped contents of module/uwsgi. func AssetUwsgi() string { - return "eJzEl8tvAjcQxu/8FaOcWglQe+VQKVKiKoe2KaRNbxuzngULr70Zj9ksf33lffBcNqgyqm8h5vt+48f4YwIbrGbgS7dSIwBWrHEGD/598evLwwhAoktJFaysmcEvIwBo5kJupdc4AiDUKBzOYCVGAJlCLd2snjgBI3I8iIfBVRGmkvVF+0mPw6nMsZRjwd7tP+7TC+OUqRu9Ts2oEaeNOuTIpFKH3GIczTznOmZjy0JPCT89OnYnUzpObc3q7B8DUGG8BVHoRGEtjNQoB/zxK8VaLS7BFdlT75IUY4JElu5Uf+0APQ7nmyDkfTiE/N69UDKS6yvZFJ0D1b/jpaUN0jSa3Xut941bvOpau+KmIkVaH8ALj/9qvmDBCDZr9cfwM6gMHCutYe8FBsvD4bO8RiqVQ/hpiDRyB/jd50ukQLoHcUhblLCsgNfKtb5DSBI1i+R/AgORMVL3h3KhO1shUUK5RhPuVLpGCb89/pPMn//863nxthiqJXqDe94LAgnlrnTX1n0tSGwUqSS13nAkgieyRYHysI5hAVWO1vMQi1MrI3S0ZcgVM0poVeGywF775NOjx+hHqqMohaovIltY4uDz11GdJ4QDzwar0tJ597qtSbXR4Id0jaIYQyG8w3GgHMPSu2oMSmr8cbAtuIhUc3RKomFYIMNC7XAKOeaWKkg9ERrWFXjXXEXRddhp6HBCl6JysEOywFTBx2TSfHNCWFjiD7C1a9iE4+DWW9PW7SLt/N+K2At9WY9TOwThwnlAGY7BHcshb4wyqyTcvcgveCsNF9IXj4crRGmitpd5o/n9jeavWGmJhHH7frIbrFhsVwnFKvVxiyRWCGEZrXF4fb1TSxgvObWP28vTda9mShIxHIpw0Tvr1yHv7mGZ1gE1erPm05DepIAbaEJTVWn8t6OWhUxpbFj6w/opC1nPGGt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Q=" } diff --git a/metricbeat/module/uwsgi/status/_meta/data.json b/metricbeat/module/uwsgi/status/_meta/data.json index c9ce9d055b1..6ed184123f1 100644 --- a/metricbeat/module/uwsgi/status/_meta/data.json +++ b/metricbeat/module/uwsgi/status/_meta/data.json @@ -6,24 +6,20 @@ "module": "uwsgi" }, "metricset": { - "name": "status" + "name": "status", + "period": 10000 }, "service": { - "address": "127.0.0.1:9192", + "address": "172.28.0.3:9191", "type": "uwsgi" }, "uwsgi": { "status": { - "core": { - "id": 1, + "total": { + "exceptions": 0, + "pid": 1, "read_errors": 0, - "requests": { - "offloaded": 0, - "routed": 0, - "static": 0, - "total": 941 - }, - "worker_pid": 7, + "requests": 2, "write_errors": 0 } } diff --git a/metricbeat/module/uwsgi/status/_meta/data_core.json b/metricbeat/module/uwsgi/status/_meta/data_core.json new file mode 100644 index 00000000000..8e2f80cd87c --- /dev/null +++ b/metricbeat/module/uwsgi/status/_meta/data_core.json @@ -0,0 +1,32 @@ +{ + "@timestamp": "2017-10-12T08:05:34.853Z", + "event": { + "dataset": "uwsgi.status", + "duration": 115000, + "module": "uwsgi" + }, + "metricset": { + "name": "status", + "period": 10000 + }, + "service": { + "address": "172.28.0.3:9191", + "type": "uwsgi" + }, + "uwsgi": { + "status": { + "core": { + "id": 1, + "read_errors": 0, + "requests": { + "offloaded": 0, + "routed": 0, + "static": 0, + "total": 1 + }, + "worker_pid": 8, + "write_errors": 0 + } + } + } +} \ No newline at end of file diff --git a/metricbeat/module/uwsgi/status/_meta/data_worker.json b/metricbeat/module/uwsgi/status/_meta/data_worker.json new file mode 100644 index 00000000000..552931163fd --- /dev/null +++ b/metricbeat/module/uwsgi/status/_meta/data_worker.json @@ -0,0 +1,38 @@ +{ + "@timestamp": "2017-10-12T08:05:34.853Z", + "event": { + "dataset": "uwsgi.status", + "duration": 115000, + "module": "uwsgi" + }, + "metricset": { + "name": "status", + "period": 10000 + }, + "service": { + "address": "172.28.0.3:9191", + "type": "uwsgi" + }, + "uwsgi": { + "status": { + "worker": { + "accepting": 1, + "avg_rt": 74, + "delta_requests": 2, + "exceptions": 0, + "harakiri_count": 0, + "id": 1, + "pid": 8, + "requests": 2, + "respawn_count": 1, + "rss": 6791168, + "running_time": 202, + "signal_queue": 0, + "signals": 0, + "status": "idle", + "tx": 110, + "vsz": 9187328 + } + } + } +} \ No newline at end of file diff --git a/metricbeat/module/uwsgi/status/_meta/fields.yml b/metricbeat/module/uwsgi/status/_meta/fields.yml index c01dbb0114c..ce770e8d260 100644 --- a/metricbeat/module/uwsgi/status/_meta/fields.yml +++ b/metricbeat/module/uwsgi/status/_meta/fields.yml @@ -65,7 +65,7 @@ description: > Worker status (cheap, pause, sig, busy, idle) - name: worker.rss - type: keyword + type: long description: > Resident Set Size. memory currently used by a process. if always zero try `--memory-report` option of uwsgi - name: worker.vsz diff --git a/metricbeat/module/uwsgi/status/status_integration_test.go b/metricbeat/module/uwsgi/status/status_integration_test.go index cfcf9271dc6..a9f32e6690d 100644 --- a/metricbeat/module/uwsgi/status/status_integration_test.go +++ b/metricbeat/module/uwsgi/status/status_integration_test.go @@ -24,6 +24,7 @@ import ( "github.com/stretchr/testify/assert" + "github.com/elastic/beats/v7/libbeat/common" "github.com/elastic/beats/v7/libbeat/tests/compose" mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing" ) @@ -46,11 +47,19 @@ func TestFetchTCP(t *testing.T) { func TestData(t *testing.T) { service := compose.EnsureUp(t, "uwsgi_http") - f := mbtest.NewReportingMetricSetV2Error(t, getConfig("http", service.Host())) - - if err := mbtest.WriteEventsReporterV2Error(f, t, ""); err != nil { - t.Fatal("write", err) - } + f := mbtest.NewFetcher(t, getConfig("http", service.Host())) + f.WriteEventsCond(t, "", func(event common.MapStr) bool { + isOverall, _ := event.HasKey("uwsgi.status.total") + return isOverall + }) + f.WriteEventsCond(t, "_meta/data_core.json", func(event common.MapStr) bool { + isCore, _ := event.HasKey("uwsgi.status.core") + return isCore + }) + f.WriteEventsCond(t, "_meta/data_worker.json", func(event common.MapStr) bool { + isWorker, _ := event.HasKey("uwsgi.status.worker") + return isWorker + }) } func TestFetchHTTP(t *testing.T) {