Skip to content

Commit 4ab2d95

Browse files
[receiver/splunkenterprisereceiver] Add splunk.indexer.rollingrestart.status metric (#39023)
…eceiver <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Add `splunk.indexer.rollingrestart.status` to splunkenterprisereceiver <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Co-authored-by: Antoine Toulme <[email protected]>
1 parent 02fd63e commit 4ab2d95

File tree

12 files changed

+255
-7
lines changed

12 files changed

+255
-7
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: 'enhancement'
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: splunkenterprisereceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "adds `splunk.indexer.rollingrestart.status` metric"
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [39023]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

receiver/splunkenterprisereceiver/documentation.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,23 @@ Gauge tracking the number of raw write seconds per instance
251251
| splunk.splunkd.build | The build number for this Splunk instance version | Any Str |
252252
| splunk.splunkd.version | The splunkd version number | Any Str |
253253

254+
### splunk.indexer.rollingrestart.status
255+
256+
The status of a rolling restart.
257+
258+
| Unit | Metric Type | Value Type |
259+
| ---- | ----------- | ---------- |
260+
| {status} | Gauge | Int |
261+
262+
#### Attributes
263+
264+
| Name | Description | Values |
265+
| ---- | ----------- | ------ |
266+
| splunk.searchable.restart | Boolean that indicates if a searchable rolling restart/upgrade in progress.t | Any Bool |
267+
| splunk.rollingorrestart | Boolean that indicates if there is a rolling restart or rolling upgrade in progress. | Any Bool |
268+
| splunk.splunkd.build | The build number for this Splunk instance version | Any Str |
269+
| splunk.splunkd.version | The splunkd version number | Any Str |
270+
254271
### splunk.indexer.throughput
255272

256273
Gauge tracking average bytes per second throughput of indexer. *Note:** Must be pointed at specific indexer `endpoint` and gathers metrics from only that indexer.

receiver/splunkenterprisereceiver/internal/metadata/generated_config.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/splunkenterprisereceiver/internal/metadata/generated_config_test.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/splunkenterprisereceiver/internal/metadata/generated_metrics.go

Lines changed: 66 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/splunkenterprisereceiver/internal/metadata/generated_metrics_test.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/splunkenterprisereceiver/internal/metadata/testdata/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ all_set:
2929
enabled: true
3030
splunk.indexer.raw.write.time:
3131
enabled: true
32+
splunk.indexer.rollingrestart.status:
33+
enabled: true
3234
splunk.indexer.throughput:
3335
enabled: true
3436
splunk.indexes.avg.size:
@@ -121,6 +123,8 @@ none_set:
121123
enabled: false
122124
splunk.indexer.raw.write.time:
123125
enabled: false
126+
splunk.indexer.rollingrestart.status:
127+
enabled: false
124128
splunk.indexer.throughput:
125129
enabled: false
126130
splunk.indexes.avg.size:

receiver/splunkenterprisereceiver/metadata.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ attributes:
5454
splunk.search.state:
5555
description: The dispatch state of the search
5656
type: string
57+
splunk.searchable.restart:
58+
description: Boolean that indicates if a searchable rolling restart/upgrade in progress.t
59+
type: bool
60+
splunk.rollingorrestart:
61+
description: Boolean that indicates if there is a rolling restart or rolling upgrade in progress.
62+
type: bool
5763

5864
metrics:
5965
splunk.license.index.usage:
@@ -368,6 +374,14 @@ metrics:
368374
gauge:
369375
value_type: int
370376
attributes: [splunk.feature, splunk.feature.health, splunk.splunkd.build, splunk.splunkd.version]
377+
# `services/cluster/manager/status`
378+
splunk.indexer.rollingrestart.status:
379+
enabled: false
380+
description: The status of a rolling restart.
381+
unit: "{status}"
382+
gauge:
383+
value_type: int
384+
attributes: [splunk.searchable.restart, splunk.rollingorrestart, splunk.splunkd.build, splunk.splunkd.version]
371385

372386
# Search Metrics
373387
splunk.search.duration:

receiver/splunkenterprisereceiver/scraper.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func (s *splunkScraper) scrape(ctx context.Context) (pmetric.Metrics, error) {
106106
s.scrapeSearchArtifacts,
107107
s.scrapeHealth,
108108
s.scrapeSearch,
109+
s.scrapeIndexerClusterManagerStatus,
109110
}
110111
errChan := make(chan error, len(metricScrapes))
111112

@@ -2060,3 +2061,39 @@ func (s *splunkScraper) setSearchJobTTLByID(sid string) error {
20602061

20612062
return nil
20622063
}
2064+
2065+
// Scrape Indexer Cluster Manger Status Endpoint
2066+
func (s *splunkScraper) scrapeIndexerClusterManagerStatus(_ context.Context, now pcommon.Timestamp, info infoDict, errs chan error) {
2067+
if !s.conf.Metrics.SplunkIndexerRollingrestartStatus.Enabled {
2068+
return
2069+
}
2070+
2071+
i := info[typeCm].Entries[0].Content
2072+
2073+
ept := apiDict[`SplunkIndexerClusterManagerStatus`]
2074+
var icms indexersClusterManagerStatus
2075+
2076+
req, err := s.splunkClient.createAPIRequest(typeCm, ept)
2077+
if err != nil {
2078+
errs <- err
2079+
return
2080+
}
2081+
res, err := s.splunkClient.makeRequest(req)
2082+
if err != nil {
2083+
errs <- err
2084+
return
2085+
}
2086+
defer res.Body.Close()
2087+
2088+
if err := json.NewDecoder(res.Body).Decode(&icms); err != nil {
2089+
errs <- err
2090+
return
2091+
}
2092+
2093+
for _, ic := range icms.Entries {
2094+
if ic.Content.RollingRestartOrUpgrade {
2095+
s.mb.RecordSplunkIndexerRollingrestartStatusDataPoint(now, 1, ic.Content.SearchableRolling, ic.Content.RollingRestartFlag, i.Build, i.Version)
2096+
}
2097+
s.mb.RecordSplunkIndexerRollingrestartStatusDataPoint(now, 0, ic.Content.SearchableRolling, ic.Content.RollingRestartFlag, i.Build, i.Version)
2098+
}
2099+
}

0 commit comments

Comments
 (0)