Skip to content

Commit b18853a

Browse files
author
Arvind Thirumurugan
committed
simplify metric emission
Signed-off-by: Arvind Thirumurugan <[email protected]>
1 parent 8870e41 commit b18853a

File tree

4 files changed

+5
-79
lines changed

4 files changed

+5
-79
lines changed

cmd/metric-app/main.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,22 @@ package main
22

33
import (
44
"net/http"
5-
"os"
65

76
"github.com/prometheus/client_golang/prometheus"
87
"github.com/prometheus/client_golang/prometheus/promhttp"
98
)
109

1110
func main() {
12-
// Get cluster and workload information from environment variables
13-
clusterName := os.Getenv("CLUSTER_NAME")
14-
if clusterName == "" {
15-
clusterName = "unknown"
16-
}
17-
18-
workloadName := os.Getenv("WORKLOAD_NAME")
19-
if workloadName == "" {
20-
workloadName = "unknown"
21-
}
22-
2311
// Define a simple gauge metric for health with labels
24-
workloadHealth := prometheus.NewGaugeVec(
12+
workloadHealth := prometheus.NewGauge(
2513
prometheus.GaugeOpts{
2614
Name: "workload_health",
2715
Help: "Indicates if the workload is healthy (1=healthy, 0=unhealthy)",
2816
},
29-
[]string{"cluster_name", "workload_name"},
3017
)
3118

3219
// Set it to 1 (healthy) with labels
33-
workloadHealth.WithLabelValues(clusterName, workloadName).Set(1)
20+
workloadHealth.Set(1)
3421

3522
// Register metric with Prometheus default registry
3623
prometheus.MustRegister(workloadHealth)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
apiVersion: cluster.kubernetes-fleet.io/v1beta1
22
kind: MemberCluster
33
metadata:
4-
name: kind-cluster-1
4+
name: kind-cluster-3
55
spec:
66
identity:
7-
name: fleet-member-agent-cluster-1
7+
name: fleet-member-agent-cluster-3
88
kind: ServiceAccount
99
namespace: fleet-system
1010
apiGroup: ""

examples/sample-metric-app-ro.yaml

Lines changed: 0 additions & 56 deletions
This file was deleted.

examples/sample-metric-app.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ spec:
2121
spec:
2222
containers:
2323
- name: metric-app
24-
image: ghcr.io/metric-app:6d6cd69
24+
image: metric-app:local
2525
imagePullPolicy: IfNotPresent
2626
ports:
2727
- containerPort: 8080
28-
env:
29-
- name: CLUSTER_NAME
30-
value: "cluster-1"
31-
- name: WORKLOAD_NAME
32-
value: "sample-metric-app"

0 commit comments

Comments
 (0)