Skip to content

Commit bf5b15a

Browse files
committed
Log stuff
1 parent e60a6ef commit bf5b15a

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

kustomization/deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ spec:
1414
spec:
1515
containers:
1616
- name: fleet-telemetry-consumer
17-
image: quay.io/rajsinghcpre/fleet-telemetry-consumer:v0.0.1
17+
image: quay.io/rajsinghcpre/fleet-telemetry-consumer:v0.0.2
1818
command: ["/fleet-telemetry-consumer", "-config", "/etc/fleet-telemetry-consumer/config.json"]
1919
volumeMounts:
2020
- name: config-volume
2121
mountPath: /etc/fleet-telemetry-consumer
22+
ports:
23+
- containerPort: 2112
24+
name: metrics
2225
volumes:
2326
- name: config-volume
2427
configMap:

kustomization/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ kind: Kustomization
33

44
resources:
55
- deployment.yaml
6-
6+
- service.yaml
7+
- serviceMonitor.yaml
78
configMapGenerator:
89
- name: fleet-telemetry-consumer-config
910
files:

kustomization/service.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: fleet-telemetry-consumer
5+
labels:
6+
app: fleet-telemetry-consumer
7+
spec:
8+
selector:
9+
app: fleet-telemetry-consumer
10+
ports:
11+
- name: metrics
12+
port: 2112
13+
targetPort: 2112
14+
protocol: TCP

kustomization/serviceMonitor.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: monitoring.coreos.com/v1
2+
kind: ServiceMonitor
3+
metadata:
4+
name: fleet-telemetry-consumer
5+
labels:
6+
app: fleet-telemetry-consumer
7+
spec:
8+
selector:
9+
matchLabels:
10+
app: fleet-telemetry-consumer
11+
namespaceSelector:
12+
any: true
13+
endpoints:
14+
- port: metrics
15+
path: /metrics
16+
interval: 15s

main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ func main() {
9797
continue
9898
}
9999

100+
// Output the message to console
101+
vehicleDataJSON, err := json.MarshalIndent(vehicleData, "", " ")
102+
if err != nil {
103+
log.Printf("Failed to marshal vehicle data to JSON: %v\n", err)
104+
continue
105+
}
106+
fmt.Printf("Received message: %s\n", vehicleDataJSON)
107+
100108
// Process each Datum in the Payload
101109
for _, datum := range vehicleData.Data {
102110
fieldName := datum.Key.String() // Get the field name from the enum
@@ -167,8 +175,8 @@ func main() {
167175
// Handle LocationValue separately
168176
lat := v.LocationValue.Latitude
169177
lon := v.LocationValue.Longitude
170-
vehicleDataGauge.WithLabelValues(fieldName+"_latitude", vehicleData.Vin).Set(lat)
171-
vehicleDataGauge.WithLabelValues(fieldName+"_longitude", vehicleData.Vin).Set(lon)
178+
vehicleDataGauge.WithLabelValues("Latitude", vehicleData.Vin).Set(lat)
179+
vehicleDataGauge.WithLabelValues("Longitude", vehicleData.Vin).Set(lon)
172180
continue // Skip the rest since we've handled this case
173181
default:
174182
// Skip non-numeric or unsupported types

0 commit comments

Comments
 (0)