From d02638d4ff8984b0e726891f5a531df03a9a8409 Mon Sep 17 00:00:00 2001 From: Jakub Surdej Date: Tue, 19 Mar 2024 21:38:50 +0100 Subject: [PATCH] Change datatype for pipeline response (#318) --- .../collectors/nodestats/pipeline_subcollector.go | 10 +++++----- .../__snapshots__/nodestats_response_test.snap | 4 ++-- internal/fetcher/responses/nodestats_response.go | 12 +++--------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/internal/collectors/nodestats/pipeline_subcollector.go b/internal/collectors/nodestats/pipeline_subcollector.go index 73b278e5..e3cf5d4d 100644 --- a/internal/collectors/nodestats/pipeline_subcollector.go +++ b/internal/collectors/nodestats/pipeline_subcollector.go @@ -118,11 +118,11 @@ func (subcollector *PipelineSubcollector) Collect(pipeStats *responses.SinglePip metricsHelper := prometheus_helper.SimpleMetricsHelper{Channel: ch, Labels: []string{pipelineID, endpoint}} // ***** EVENTS ***** - metricsHelper.NewIntMetric(subcollector.EventsOut, prometheus.CounterValue, pipeStats.Events.Out) - metricsHelper.NewIntMetric(subcollector.EventsFiltered, prometheus.CounterValue, pipeStats.Events.Filtered) - metricsHelper.NewIntMetric(subcollector.EventsIn, prometheus.CounterValue, pipeStats.Events.In) - metricsHelper.NewIntMetric(subcollector.EventsDuration, prometheus.GaugeValue, pipeStats.Events.DurationInMillis) - metricsHelper.NewIntMetric(subcollector.EventsQueuePushDuration, prometheus.GaugeValue, pipeStats.Events.QueuePushDurationInMillis) + metricsHelper.NewInt64Metric(subcollector.EventsOut, prometheus.CounterValue, pipeStats.Events.Out) + metricsHelper.NewInt64Metric(subcollector.EventsFiltered, prometheus.CounterValue, pipeStats.Events.Filtered) + metricsHelper.NewInt64Metric(subcollector.EventsIn, prometheus.CounterValue, pipeStats.Events.In) + metricsHelper.NewInt64Metric(subcollector.EventsDuration, prometheus.GaugeValue, pipeStats.Events.DurationInMillis) + metricsHelper.NewInt64Metric(subcollector.EventsQueuePushDuration, prometheus.GaugeValue, pipeStats.Events.QueuePushDurationInMillis) // ****************** // ***** UP ***** diff --git a/internal/fetcher/responses/__snapshots__/nodestats_response_test.snap b/internal/fetcher/responses/__snapshots__/nodestats_response_test.snap index ae35fe6a..b13a0a7d 100755 --- a/internal/fetcher/responses/__snapshots__/nodestats_response_test.snap +++ b/internal/fetcher/responses/__snapshots__/nodestats_response_test.snap @@ -69,7 +69,7 @@ responses.NodeStatsResponse{ Pipelines: { ".monitoring-logstash": { Monitoring: responses.PipelineLogstashMonitoringResponse{}, - Events: struct { Out int "json:\"out\""; Filtered int "json:\"filtered\""; In int "json:\"in\""; DurationInMillis int "json:\"duration_in_millis\""; QueuePushDurationInMillis int "json:\"queue_push_duration_in_millis\"" }{}, + Events: responses.EventsResponse{}, Flow: responses.FlowResponse{}, Plugins: struct { Inputs []struct { ID string "json:\"id\""; Name string "json:\"name\""; Events struct { Out int "json:\"out\""; QueuePushDurationInMillis int "json:\"queue_push_duration_in_millis\"" } "json:\"events\"" } "json:\"inputs\""; Codecs []struct { ID string "json:\"id\""; Name string "json:\"name\""; Decode struct { Out int "json:\"out\""; WritesIn int "json:\"writes_in\""; DurationInMillis int "json:\"duration_in_millis\"" } "json:\"decode\""; Encode struct { WritesIn int "json:\"writes_in\""; DurationInMillis int "json:\"duration_in_millis\"" } "json:\"encode\"" } "json:\"codecs\""; Filters []struct { ID string "json:\"id\""; Name string "json:\"name\""; Events struct { Out int "json:\"out\""; In int "json:\"in\""; DurationInMillis int "json:\"duration_in_millis\"" } "json:\"events\"" } "json:\"filters\""; Outputs []struct { ID string "json:\"id\""; Name string "json:\"name\""; Events struct { Out int "json:\"out\""; In int "json:\"in\""; DurationInMillis int "json:\"duration_in_millis\"" } "json:\"events\""; Documents struct { Successes int "json:\"successes\""; NonRetryableFailures int "json:\"non_retryable_failures\"" } "json:\"documents\""; BulkRequests struct { WithErrors int "json:\"with_errors\""; Responses map[string]int "json:\"responses\"" } "json:\"bulk_requests\"" } "json:\"outputs\"" }{ Inputs: { @@ -89,7 +89,7 @@ responses.NodeStatsResponse{ }, "main": { Monitoring: responses.PipelineLogstashMonitoringResponse{}, - Events: struct { Out int "json:\"out\""; Filtered int "json:\"filtered\""; In int "json:\"in\""; DurationInMillis int "json:\"duration_in_millis\""; QueuePushDurationInMillis int "json:\"queue_push_duration_in_millis\"" }{Out:0, Filtered:0, In:4001, DurationInMillis:0, QueuePushDurationInMillis:0}, + Events: responses.EventsResponse{In:4001, Filtered:0, Out:0, DurationInMillis:0, QueuePushDurationInMillis:0}, Flow: responses.FlowResponse{ InputThroughput: struct { Current float64 "json:\"current\""; Lifetime float64 "json:\"lifetime\"" }{Current:6.7, Lifetime:124}, FilterThroughput: struct { Current float64 "json:\"current\""; Lifetime float64 "json:\"lifetime\"" }{Current:7.8, Lifetime:8.9}, diff --git a/internal/fetcher/responses/nodestats_response.go b/internal/fetcher/responses/nodestats_response.go index 605cddf0..fd6a7376 100644 --- a/internal/fetcher/responses/nodestats_response.go +++ b/internal/fetcher/responses/nodestats_response.go @@ -99,15 +99,9 @@ type FlowResponse struct { type SinglePipelineResponse struct { Monitoring PipelineLogstashMonitoringResponse `json:".monitoring-logstash"` - Events struct { - Out int `json:"out"` - Filtered int `json:"filtered"` - In int `json:"in"` - DurationInMillis int `json:"duration_in_millis"` - QueuePushDurationInMillis int `json:"queue_push_duration_in_millis"` - } `json:"events"` - Flow FlowResponse `json:"flow"` - Plugins struct { + Events EventsResponse `json:"events"` + Flow FlowResponse `json:"flow"` + Plugins struct { Inputs []struct { ID string `json:"id"` Name string `json:"name"`