Skip to content

Commit

Permalink
Add stack monitoring telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
robbavey committed Mar 22, 2023
1 parent c3b3b9c commit b2bf2d9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ webhooks:
- logstashes
sideEffects: None
- admissionReviewVersions:
- v1alpha1
- v1
- v1beta1
clientConfig:
Expand Down
14 changes: 7 additions & 7 deletions pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ func logstashStats(k8sClient k8s.Client, managedNamespaces []string) (string, in
}

for _, ls := range logstashList.Items {
ls := ls
stats[resourceCount]++
stats[serviceCount] += int32(len(ls.Spec.Services))
stats[podCount] += ls.Status.AvailableNodes
Expand All @@ -424,13 +425,12 @@ func logstashStats(k8sClient k8s.Client, managedNamespaces []string) (string, in
// if ls.Spec.Pipelines != nil {
// stats[pipelinesRefCount] ++
//}
// TODO: Add when stack monitoring PR is merged
// if monitoring.IsLogsDefined(&ls) {
// stats[stackMonitoringLogsCount]++
//}
// if monitoring.IsMetricsDefined(&ls) {
// stats[stackMonitoringMetricsCount]++
//}
if monitoring.IsLogsDefined(&ls) {
stats[stackMonitoringLogsCount]++
}
if monitoring.IsMetricsDefined(&ls) {
stats[stackMonitoringMetricsCount]++
}
}
}
return "logstashes", stats, nil
Expand Down
8 changes: 6 additions & 2 deletions pkg/telemetry/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ func TestNewReporter(t *testing.T) {
},
Spec: logstashv1alpha1.LogstashSpec{
Count: 3,
Monitoring: commonv1.Monitoring{
Logs: commonv1.LogsMonitoring{ElasticsearchRefs: []commonv1.ObjectSelector{{Name: "monitoring"}}},
Metrics: commonv1.MetricsMonitoring{ElasticsearchRefs: []commonv1.ObjectSelector{{Name: "monitoring"}}},
},
Services: []logstashv1alpha1.LogstashService{
{
Name: "test1",
Expand Down Expand Up @@ -457,8 +461,8 @@ func TestNewReporter(t *testing.T) {
pod_count: 3
resource_count: 1
service_count: 2
stack_monitoring_logs_count: 0
stack_monitoring_metrics_count: 0
stack_monitoring_logs_count: 1
stack_monitoring_metrics_count: 1
maps:
pod_count: 1
resource_count: 1
Expand Down

0 comments on commit b2bf2d9

Please sign in to comment.