Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make kibana/stats metricset work for Stack Monitoring without xpack.enabled flag #21496

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28375,11 +28375,15 @@ Kibana module



[float]
=== kibana

*`kibana.stats.usage.name`*::
+
--
type: alias

alias to: kibana.stats.usage.index

--

[float]
=== stats
Expand All @@ -28388,6 +28392,14 @@ Kibana stats and run-time metrics.




*`kibana.stats.usage.index`*::
+
--
type: keyword

--

*`kibana.stats.uuid`*::
+
--
Expand Down
4 changes: 3 additions & 1 deletion metricbeat/module/kibana/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
fields:
- name: kibana
type: group
description: >
fields:
- name: stats.usage.name
type: alias
path: kibana.stats.usage.index
2 changes: 1 addition & 1 deletion metricbeat/module/kibana/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 3 additions & 31 deletions metricbeat/module/kibana/kibana_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
package kibana_test

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/elastic/beats/v7/libbeat/tests/compose"
mbtest "github.com/elastic/beats/v7/metricbeat/mb/testing"
"github.com/elastic/beats/v7/metricbeat/module/kibana"
_ "github.com/elastic/beats/v7/metricbeat/module/kibana/stats"
)
Expand All @@ -34,32 +28,10 @@ var xpackMetricSets = []string{
"stats",
}

func TestXPackEnabled(t *testing.T) {
service := compose.EnsureUpWithTimeout(t, 300, "kibana")

metricSetToTypeMap := map[string]string{
"stats": "kibana_stats",
}

config := getXPackConfig(service.Host())

metricSets := mbtest.NewReportingMetricSetV2Errors(t, config)
for _, metricSet := range metricSets {
events, errs := mbtest.ReportingFetchV2Error(metricSet)
require.Empty(t, errs)
require.NotEmpty(t, events)

event := events[0]
require.Equal(t, metricSetToTypeMap[metricSet.Name()], event.RootFields["type"])
require.Regexp(t, `^.monitoring-kibana-\d-mb`, event.Index)
}
}

func getXPackConfig(host string) map[string]interface{} {
return map[string]interface{}{
"module": kibana.ModuleName,
"metricsets": xpackMetricSets,
"hosts": []string{host},
"xpack.enabled": true,
"module": kibana.ModuleName,
"metricsets": xpackMetricSets,
"hosts": []string{host},
}
}
2 changes: 0 additions & 2 deletions metricbeat/module/kibana/metricset.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
// MetricSet can be used to build other metricsets within the Kibana module.
type MetricSet struct {
mb.BaseMetricSet
XPackEnabled bool
}

// NewMetricSet creates a metricset that can be used to build other metricsets
Expand All @@ -37,6 +36,5 @@ func NewMetricSet(base mb.BaseMetricSet) (*MetricSet, error) {

return &MetricSet{
base,
config.XPackEnabled,
}, nil
}
103 changes: 76 additions & 27 deletions metricbeat/module/kibana/stats/_meta/data.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,122 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"agent": {
"hostname": "host.example.com",
"name": "host.example.com"
},
"elasticsearch": {
"cluster": {
"id": "hyK0oDhoThywCtJd2DV8Bg"
}
},
"event": {
"dataset": "kibana.stats",
"duration": 115000,
"module": "kibana"
},
"kibana": {
"elasticsearch": {
"cluster": {
"id": "zJpGlM76SkSnRMK1Ihihnw"
}
},
"stats": {
"concurrent_connections": 1,
"concurrent_connections": 0,
"host": {
"name": "localhost"
"name": "0"
},
"index": "kibana",
"kibana": {
"host": "0",
"index": ".kibana",
"name": "kibana",
"snapshot": false,
"status": "green",
"transport_address": "0:5601",
"uuid": "47c5b96a-e3c4-430c-afee-5c7e27683b80",
"version": "7.9.0"
},
"name": "kibana",
"os": {
"distro": "Centos",
"distroRelease": "Centos-7.8.2003",
"load": {
"15m": 1.1416015625,
"1m": 1.18994140625,
"5m": 1.28466796875
},
"memory": {
"free_in_bytes": 11949064192,
"total_in_bytes": 33300463616,
"used_in_bytes": 21351399424
},
"platform": "linux",
"platformRelease": "linux-5.6.10-arch1-1",
"uptime_in_millis": 11437000
},
"index": "Shaunaks-MBP-2.attlocal.net",
"name": "Shaunaks-MBP-2.attlocal.net",
"process": {
"event_loop_delay": {
"ms": 0.45250000059604645
"ms": 0.13968499936163425
},
"memory": {
"heap": {
"size_limit": {
"bytes": 1526909922
},
"total": {
"bytes": 307593216
"bytes": 475709440
},
"used": {
"bytes": 226887112
"bytes": 337236176
}
},
"resident_set_size": {
"bytes": 592297984
}
},
"uptime": {
"ms": 124098
"ms": 373166
}
},
"request": {
"disconnects": 0,
"total": 0
"total": 4
},
"response_time": {
"avg": {},
"avg": {
"ms": 5
},
"max": {
"ms": 0
"ms": 6
}
},
"snapshot": false,
"status": "green"
"status": "green",
"usage": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the recent changes in #22732, I don't think we even need to collect usage any more. WDYT @chrisronline - safe to omit usage collection in this PR here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Please remove it

"dashboard": {
"total": 0
},
"graph_workspace": {
"total": 0
},
"index": ".kibana",
"index_pattern": {
"total": 0
},
"search": {
"total": 0
},
"timelion_sheet": {
"total": 0
},
"visualization": {
"total": 0
}
}
}
},
"metricset": {
"name": "stats"
"name": "stats",
"period": 10000
},
"process": {
"pid": 93807
"pid": 6
},
"service": {
"address": "127.0.0.1:5601",
"id": "5b2de169-2785-441b-ae8c-186a1936b17d",
"name": "kibana",
"address": "172.26.0.3:5601",
"id": "47c5b96a-e3c4-430c-afee-5c7e27683b80",
"type": "kibana",
"version": "7.0.0"
"version": "7.9.0"
}
}
5 changes: 5 additions & 0 deletions metricbeat/module/kibana/stats/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
Kibana stats and run-time metrics.
release: ga
fields:
- name: usage
type: group
fields:
- name: index
type: keyword
- name: uuid
type: alias
path: service.id
Expand Down
55 changes: 55 additions & 0 deletions metricbeat/module/kibana/stats/_meta/settings_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"@timestamp": "2020-10-02T16:14:24.034Z",
"@metadata": {
"beat": "metricbeat",
"type": "_doc",
"version": "8.0.0"
},
"kibana": {
"stats": {
"settings": {
ycombinator marked this conversation as resolved.
Show resolved Hide resolved
"version": "8.0.0",
"index": ".kibana",
"port": 5601,
"transport_address": "0:5601",
"locale": "en",
"snapshot": true,
"status": "green",
"uuid": "0b55ab2a-5fdc-4097-9a46-a3d35e2c1dbf",
"name": "kibana",
"host": "0"
},
"elasticsearch": {
"cluster": {
"id": "AcU_Ce_aS5W4NvGYNinnxg"
}
}
}
},
"ecs": {
"version": "1.5.0"
},
"host": {
"name": "mcastro"
},
"agent": {
"version": "8.0.0",
"ephemeral_id": "38dd3436-2a1a-449f-8f43-b8d78c358b22",
"id": "803dfdba-e638-4590-a2de-80cb1cebe78d",
"name": "mcastro",
"type": "metricbeat"
},
"event": {
"duration": 338628448,
"dataset": "kibana.stats",
"module": "kibana"
},
"metricset": {
"period": 10000,
"name": "stats"
},
"service": {
"address": "localhost:5601",
"type": "kibana"
}
}
Loading