Skip to content

Commit

Permalink
Add component.{id, binary} to monitoring metrics
Browse files Browse the repository at this point in the history
This commit adds `component.id` and `component.binary` to the
monitoring metrics, those fields are necessary to create unique TSDB
entries.
  • Loading branch information
belimawr committed Oct 19, 2023
1 parent 9196320 commit ff20b95
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions internal/pkg/agent/application/monitoring/v1_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,15 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
"ignore_missing": true,
},
},
map[string]interface{}{
"add_fields": map[string]interface{}{
"target": "component",
"fields": map[string]interface{}{
"id": "elastic-agent",
"binary": "elastic-agent",
},
},
},
},
},
}
Expand Down Expand Up @@ -655,6 +664,15 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
},
},
},
map[string]interface{}{
"add_fields": map[string]interface{}{
"target": "component",
"fields": map[string]interface{}{
"id": unit,
"binary": binaryName,
},
},
},
},
})
}
Expand Down Expand Up @@ -715,6 +733,15 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
"ignore_missing": true,
},
},
map[string]interface{}{
"add_fields": map[string]interface{}{
"target": "component",
"fields": map[string]interface{}{
"id": unit,
"binary": binaryName,
},
},
},
},
})

Expand Down Expand Up @@ -777,6 +804,15 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
"ignore_missing": true,
},
},
map[string]interface{}{
"add_fields": map[string]interface{}{
"target": "component",
"fields": map[string]interface{}{
"id": unit,
"binary": binaryName,
},
},
},
},
})
}
Expand Down Expand Up @@ -807,7 +843,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
"hosts": endpoints,
"namespace": "application",
"period": metricsCollectionIntervalString,
"processors": createProcessorsForJSONInput(name, monitoringNamespace, b.agentInfo),
"processors": createProcessorsForJSONInput(name, comp.ID, monitoringNamespace, b.agentInfo),
},
map[string]interface{}{
idKey: "metrics-monitoring-shipper-stats",
Expand All @@ -821,7 +857,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
"hosts": endpoints,
"namespace": "agent",
"period": metricsCollectionIntervalString,
"processors": createProcessorsForJSONInput(name, monitoringNamespace, b.agentInfo),
"processors": createProcessorsForJSONInput(name, comp.ID, monitoringNamespace, b.agentInfo),
})
}
}
Expand Down Expand Up @@ -878,7 +914,7 @@ func (b *BeatsMonitor) injectMetricsInput(cfg map[string]interface{}, componentI
return nil
}

func createProcessorsForJSONInput(name string, monitoringNamespace string, agentInfo *info.AgentInfo) []interface{} {
func createProcessorsForJSONInput(name string, compID, monitoringNamespace string, agentInfo *info.AgentInfo) []interface{} {
return []interface{}{
map[string]interface{}{
"add_fields": map[string]interface{}{
Expand Down Expand Up @@ -932,6 +968,15 @@ func createProcessorsForJSONInput(name string, monitoringNamespace string, agent
"ignore_missing": true,
},
},
map[string]interface{}{
"add_fields": map[string]interface{}{
"target": "component",
"fields": map[string]interface{}{
"id": compID,
"binary": name,
},
},
},
}
}

Expand Down

0 comments on commit ff20b95

Please sign in to comment.