Commit 95f416c
Adds a per-node security_stats metricset that scrapes the new
GET /_security/stats endpoint introduced in Elasticsearch 9.2.
The first metric exposed is the Document Level Security cache
(entries, memory, hits, misses, evictions, hit/miss latency),
giving Stack Monitoring fleet-wide visibility into DLS cache
health for spotting cache thrash, oversized working sets, and
unhealthy hit/miss ratios.
Each event is enriched with node name, roles, and stack version
via a single filter-path-scoped /_nodes call per scrape, shared
across all per-node events emitted in that scrape. This logic
lives on the module's MetricSet as the new NodeEnrichment helper
so future per-node metricsets can reuse it. node.version is also
declared at the module level alongside id, name, roles, master,
and mlockall.
The shared metricbeat/docker-compose.yml elasticsearch service
now runs with xpack.security.enabled=true plus an anonymous
superuser, since /_security/stats is only registered when
security is enabled. Anonymous superuser keeps the rest of the
elasticsearch integration test suite working without threading
credentials through every metricset's setup.
* docs: register security_stats metricset page in toc.yml
mage update regenerates per-metricset markdown but doesn't touch
the navigation toc.yml. Add the missing entry so docs-build can
locate the security_stats page in the Elasticsearch module section.
* docs: replace "e.g." with "for example" per Vale style guide
Elastic.Latinisms forbids Latin abbreviations in docs. Replace
the lone "e.g." in the new node.version field description and
regenerate the affected files.
* metricbeat/elasticsearch: clean up pre-existing lint issues
Two pre-existing lint findings in elasticsearch_integration_test.go
became blocking once this branch touched the file (golangci-lint
runs with --whole-files). Both fixes are mechanical:
- Replace math/rand with math/rand/v2 in randString and drop the
redundant per-call seeded local Rand.
- Add the comma-ok form to the version.number type assertion in
getElasticsearchVersion so errcheck (with check-type-assertions)
is satisfied.
* metricbeat/elasticsearch: dedupe node.version field declaration
The new module-level node.version added for security_stats collided
with a pre-existing node.version in the node metricset's local
fields.yml, breaking `metricbeat export index-pattern` with
"field <elasticsearch.node.version> is duplicated".
Drop the metricset-local declaration in favor of the shared
module-level one, which carries a richer description and is the
right scope for a field emitted by multiple per-node metricsets.
* metricbeat: provision file-realm users for secured ES test stack
Enabling xpack.security on the shared elasticsearch service for
security_stats coverage broke Kibana boot: Kibana 9.x's interactive
setup plugin holds preboot when ES has security on without
ELASTICSEARCH_USERNAME, and the existing Kibana healthchecks
(curl -u beats:testing, curl -u myelastic:changeme) started actually
validating against ES instead of being silently ignored.
Provision the named users that the existing healthchecks expect via
elasticsearch-users useradd in the startup command, and give Kibana
real ES credentials. Anonymous=superuser is preserved so the
integration tests' credential-less HTTP probes keep working without
threading credentials through every metricset's setup.
* x-pack/metricbeat: give kibana credentials to secured ES
The previous commit enabled xpack.security on the shared Elasticsearch
service and gave the OSS metricbeat kibana service real credentials,
but x-pack/metricbeat hand-copies its kibana stanza (depends_on can't
be extended) so the env didn't propagate. With no
ELASTICSEARCH_USERNAME, Kibana entered interactive setup, the
Dockerfile healthcheck (curl -u myelastic:changeme /api/stats) never
reached green, and the proxy_dep busybox blocked all integration
tests from starting.
Mirror the env vars into the x-pack kibana stanza and note the
duplication contract in a comment so future secured-ES changes are
applied in both places.
* metricbeat/elasticsearch: gate security_stats on xpack feature flag
CI exposed that the previous PR commits enabled xpack.security on the
shared metricbeat docker-compose stack to exercise /_security/stats,
but that change rippled wider than fits in this PR: Kibana boot,
healthcheck users, OTel test framework default credentials, and the
Python `get_version` helper all assume an open ES. Revert both
metricbeat and x-pack/metricbeat docker-compose.yml to their
upstream/main shape and address the underlying problem in the
metricset itself.
`security_stats.checkAvailability` now mirrors the pattern used by
ccr and ml_job: a free in-memory version comparison short-circuits
old clusters first, then a proactive `GET /_xpack` probe checks
`features.security.enabled` so we can emit a specific operator-facing
log message and avoid hitting an endpoint we know would return 400.
A new `Security` field is added to the shared `elasticsearch.XPack`
struct to support the check.
The elasticsearch_integration_test.go suite skips security_stats
unconditionally for now, with a TODO pointing at a focused follow-up
PR that migrates the metricbeat compose stack to an x-pack-security-
enabled posture (file-realm users, Kibana credentials, test fixture
auth). At that point the skip becomes vacuous and the metricset is
exercised against a real /_security/stats response.
---------
(cherry picked from commit 7119b64)
Co-authored-by: Elliot Barlas <elliotbarlas@gmail.com>
Co-authored-by: Visha Angelova <91186315+vishaangelova@users.noreply.github.com>
1 parent b1557cf commit 95f416c
23 files changed
Lines changed: 855 additions & 22 deletions
File tree
- changelog/fragments
- docs/reference
- metricbeat
- metricbeat
- include
- modules.d
- module/elasticsearch
- _meta
- node/_meta
- security_stats
- _meta
- test
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
Lines changed: 66 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
982 | 982 | | |
983 | 983 | | |
984 | 984 | | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
985 | 991 | | |
986 | 992 | | |
987 | 993 | | |
| |||
2096 | 2102 | | |
2097 | 2103 | | |
2098 | 2104 | | |
2099 | | - | |
2100 | | - | |
2101 | | - | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
2105 | 2105 | | |
2106 | 2106 | | |
2107 | 2107 | | |
| |||
2874 | 2874 | | |
2875 | 2875 | | |
2876 | 2876 | | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
| 2880 | + | |
| 2881 | + | |
| 2882 | + | |
| 2883 | + | |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
2877 | 2937 | | |
2878 | 2938 | | |
2879 | 2939 | | |
| |||
Lines changed: 85 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
935 | 935 | | |
936 | 936 | | |
937 | 937 | | |
| 938 | + | |
938 | 939 | | |
939 | 940 | | |
940 | 941 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
333 | 338 | | |
334 | 339 | | |
335 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
336 | 344 | | |
337 | 345 | | |
338 | 346 | | |
| |||
0 commit comments