Skip to content

[receiver/splunkenterprisereceiver] Add splunk.indexer.rollingrestart.status metric #39023

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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
28b094b
Add splunk.indexer.rolling.restart.status metric to splunkenterpriser…
juanhotencoding Mar 27, 2025
eaf55fe
fix naming
juanhotencoding Mar 27, 2025
ce9e048
update logic for setting metric
juanhotencoding Mar 27, 2025
db22c7c
Merge branch 'main' of github.com:juanhotencoding/opentelemetry-colle…
juanhotencoding Mar 31, 2025
1a5540c
fmt
juanhotencoding Mar 31, 2025
6dc65b2
Merge branch 'main' of github.com:juanhotencoding/opentelemetry-colle…
juanhotencoding Apr 7, 2025
228e1e8
rebase
juanhotencoding Apr 14, 2025
70773a0
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 15, 2025
0303af5
fix metadata.yml
juanhotencoding Apr 15, 2025
b1431d3
fix search_result file
juanhotencoding Apr 15, 2025
f428e6a
fix conflicts
juanhotencoding Apr 15, 2025
9b1cc77
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 15, 2025
9e62f15
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 16, 2025
489ea3a
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 17, 2025
a0c1bf1
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 21, 2025
e474c60
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 22, 2025
2816dc0
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 22, 2025
760235e
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 22, 2025
4dee19b
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 22, 2025
a2fcf65
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 23, 2025
86aa8bf
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 23, 2025
7329470
Merge branch 'main' into add-splunk-rolling-restart-metric
atoulme Apr 24, 2025
111af0c
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 24, 2025
d8fb90f
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 28, 2025
a3a8122
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 29, 2025
25a5bfa
Merge branch 'main' into add-splunk-rolling-restart-metric
atoulme Apr 29, 2025
baa43da
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 29, 2025
7026ec4
regenerate and add chlog
juanhotencoding Apr 29, 2025
a2e5912
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding Apr 30, 2025
6860193
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 1, 2025
58c118a
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 1, 2025
5cd513a
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 1, 2025
d4f5e8b
Merge branch 'main' into add-splunk-rolling-restart-metric
atoulme May 2, 2025
f74d091
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 2, 2025
e55ac47
fix issues
juanhotencoding May 2, 2025
19c17a2
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 2, 2025
8ad893e
fix lint issues
juanhotencoding May 5, 2025
04d80c7
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 5, 2025
f3f126f
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 5, 2025
63a7f40
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 6, 2025
253d595
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 6, 2025
9cfeb88
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 6, 2025
6bf5c3d
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 6, 2025
be06d28
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 6, 2025
1a67042
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 6, 2025
1113ef7
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 7, 2025
59658ea
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 7, 2025
de4bb0a
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 7, 2025
1a79df3
use build and version info in metric
juanhotencoding May 7, 2025
fb63ec2
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 7, 2025
a4ef9e5
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 7, 2025
555887e
fix tests
juanhotencoding May 7, 2025
1774ea3
Merge branch 'main' into add-splunk-rolling-restart-metric
juanhotencoding May 7, 2025
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
15 changes: 15 additions & 0 deletions receiver/splunkenterprisereceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,21 @@ The status ('red', 'yellow', or 'green') of the Splunk server. Health of 'red' p
| splunk.feature | The Feature name from the Splunk Health Introspection Endpoint | Any Str |
| splunk.feature.health | The Health (in color form) of a Splunk Feature from the Splunk Health Introspection Endpoint | Any Str |

### splunk.indexer.rollingrestart.status

The status of a rolling restart.

| Unit | Metric Type | Value Type |
| ---- | ----------- | ---------- |
| {status} | Gauge | Int |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| splunk.searchable.restart | String that indicates if a searchable rolling restart/upgrade in progress.t | Any Str |
| splunk.rollingorrestart | String that indicates if there is a rolling restart or rolling upgrade in progress. | Any Str |

### splunk.indexer.throughput

Gauge tracking average bytes per second throughput of indexer. *Note:** Must be pointed at specific indexer `endpoint` and gathers metrics from only that indexer.
Expand Down
3 changes: 1 addition & 2 deletions receiver/splunkenterprisereceiver/generated_package_test.go

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

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

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

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ all_set:
enabled: true
splunk.indexer.raw.write.time:
enabled: true
splunk.indexer.rollingrestart.status:
enabled: true
splunk.indexer.throughput:
enabled: true
splunk.indexes.avg.size:
Expand Down Expand Up @@ -113,6 +115,8 @@ none_set:
enabled: false
splunk.indexer.raw.write.time:
enabled: false
splunk.indexer.rollingrestart.status:
enabled: false
splunk.indexer.throughput:
enabled: false
splunk.indexes.avg.size:
Expand Down
14 changes: 14 additions & 0 deletions receiver/splunkenterprisereceiver/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ attributes:
splunk.feature.health:
description: The Health (in color form) of a Splunk Feature from the Splunk Health Introspection Endpoint
type: string
splunk.searchable.restart:
description: String that indicates if a searchable rolling restart/upgrade in progress.t
type: string
splunk.rollingorrestart:
description: String that indicates if there is a rolling restart or rolling upgrade in progress.
type: string

metrics:
splunk.license.index.usage:
Expand Down Expand Up @@ -359,6 +365,14 @@ metrics:
gauge:
value_type: int
attributes: [splunk.feature, splunk.feature.health]
# `services/cluster/manager/status`
splunk.indexer.rollingrestart.status:
enabled: false
description: The status of a rolling restart.
unit: "{status}"
gauge:
value_type: int
attributes: [splunk.searchable.restart, splunk.rollingorrestart]

tests:
config:
54 changes: 54 additions & 0 deletions receiver/splunkenterprisereceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1786,3 +1786,57 @@ func (s *splunkScraper) traverseHealthDetailFeatures(details healthDetails, now
s.traverseHealthDetailFeatures(feature, now)
}
}

// Scrape Indexer Cluster Manger Status Endpoint
func (s *splunkScraper) scrapeIndexerClusterManagerStatus(ctx context.Context, now pcommon.Timestamp, errs chan error) {
if !s.conf.MetricsBuilderConfig.Metrics.SplunkIndexerRollingRestartStatus.Enabled {
return
}

ctx = context.WithValue(ctx, endpointType("type"), typeCm)

ept := apiDict[`SplunkIndexerClusterManagerStatus`]
var icms indexersClusterManagerStatus

req, err := s.splunkClient.createAPIRequest(ctx, ept)
if err != nil {
errs <- err
return
}

res, err := s.splunkClient.makeRequest(req)
if err != nil {
errs <- err
return
}
defer res.Body.Close()

if err := json.NewDecoder(res.Body).Decode(&icms); err != nil {
errs <- err
return
}

restartOrUpgrade := "false"
if icms.Entry.Content.RollingRestartOrUpgrade {
restartOrUpgrade = "true"
}

searchable := "false"
if icms.Entry.Content.SearchableRolling {
searchable = "true"
}

restarting := icms.Entry.Content.RollingRestartOrUpgrade || icms.Entry.Content.SearchableRolling || icms.Entry.Content.RollingRestartFlag

for _, mtsRestartOrUpgrade := range []string{"false", "true"} {
for _, mtsSearchable := range []string{"false", "true"} {
if restartOrUpgrade == mtsRestartOrUpgrade && searchable == mtsSearchable && restarting {
// If we're restarting, put a 1 in the gauge that matches the current state
s.mb.RecordSplunkIndexerRollingrestartStatusDataPoint(now, 1, mtsRestartOrUpgrade, mtsSearchable)
} else {
// Put a zero in all the other gauges
s.mb.RecordSplunkIndexerRollingrestartStatusDataPoint(now, 0, mtsRestartOrUpgrade, mtsSearchable)
}
}
}
}
20 changes: 19 additions & 1 deletion receiver/splunkenterprisereceiver/search_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var apiDict = map[string]string{
`SplunkKVStoreStatus`: `/services/kvstore/status?output_mode=json`,
`SplunkDispatchArtifacts`: `/services/server/status/dispatch-artifacts?output_mode=json&count=-1`,
`SplunkHealth`: `/services/server/health/splunkd/details?output_mode=json`,
`SplunkIndexerClusterManagerStatus`: `/services/cluster/manager/status?output_mode=json`,
}

type searchResponse struct {
Expand Down Expand Up @@ -158,7 +159,7 @@ type dispatchArtifactContent struct {
CacheTotalEntries string `json:"cached_job_status_total_entries"`
}

// '/services/server/health/splunkd/details
// '/services/server/health/splunkd/details'
type healthArtifacts struct {
Entries []healthArtifactEntry `json:"entry"`
}
Expand All @@ -171,3 +172,20 @@ type healthDetails struct {
Health string `json:"health"`
Features map[string]healthDetails `json:"features,omitempty"`
}

// '/services/cluster/manager/status'
type indexersClusterManagerStatus struct {
Entry idxClusterManagerStatusEntry
}
type idxClusterManagerStatusEntry struct {
Name string `json:"name"`
Content idxClusterManagerStatusContent `json:"content"`
}

type idxClusterManagerStatusContent struct {
RollingRestartFlag bool `json:"rolling_restart_flag,omitempty"`
RollingRestartOrUpgrade bool `json:"rolling_restart_or_upgrade,omitempty"`
RollingRestartType string `json:"rolling_restart_type,omitempty"`
SearchableRolling bool `json:"searchable_rolling,omitempty"`
ServiceReadyFlag bool `json:"service_ready_flag,omitempty"`
}