|
1 | 1 | package main |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "log" |
5 | | - "fmt" |
6 | | - "time" |
7 | | - "net/http" |
8 | 4 | "encoding/json" |
| 5 | + "fmt" |
9 | 6 | "github.com/prometheus/client_golang/prometheus" |
10 | 7 | "github.com/prometheus/client_golang/prometheus/promhttp" |
| 8 | + "log" |
| 9 | + "net/http" |
| 10 | + "time" |
11 | 11 | ) |
12 | 12 |
|
13 | 13 | type AzureScheduledEventResponse struct { |
14 | | - DocumentIncarnation int `json:"DocumentIncarnation"` |
15 | | - Events []AzureScheduledEvent `json:"Events"` |
| 14 | + DocumentIncarnation int `json:"DocumentIncarnation"` |
| 15 | + Events []AzureScheduledEvent `json:"Events"` |
16 | 16 | } |
17 | 17 |
|
18 | 18 | type AzureScheduledEvent struct { |
19 | | - EventId string `json:"EventId"` |
20 | | - EventType string `json:"EventType"` |
21 | | - ResourceType string `json:"ResourceType"` |
22 | | - Resources []string `json:"Resources"` |
23 | | - EventStatus string `json:"EventStatus"` |
24 | | - NotBefore string `json:"NotBefore"` |
| 19 | + EventId string `json:"EventId"` |
| 20 | + EventType string `json:"EventType"` |
| 21 | + ResourceType string `json:"ResourceType"` |
| 22 | + Resources []string `json:"Resources"` |
| 23 | + EventStatus string `json:"EventStatus"` |
| 24 | + NotBefore string `json:"NotBefore"` |
25 | 25 | } |
26 | 26 |
|
27 | 27 | var ( |
|
69 | 69 | apiErrorCount = 0 |
70 | 70 | ) |
71 | 71 |
|
72 | | - |
73 | 72 | func setupMetricsCollection() { |
74 | 73 | prometheus.MustRegister(scheduledEvent) |
75 | 74 | prometheus.MustRegister(scheduledEventDocumentIncarnation) |
@@ -132,30 +131,30 @@ func probeCollect() { |
132 | 131 | for _, resource := range event.Resources { |
133 | 132 | scheduledEvent.With( |
134 | 133 | prometheus.Labels{ |
135 | | - "eventID": event.EventId, |
136 | | - "eventType": event.EventType, |
| 134 | + "eventID": event.EventId, |
| 135 | + "eventType": event.EventType, |
137 | 136 | "resourceType": event.ResourceType, |
138 | | - "resource": resource, |
139 | | - "eventStatus": event.EventStatus, |
140 | | - "notBefore": event.NotBefore, |
| 137 | + "resource": resource, |
| 138 | + "eventStatus": event.EventStatus, |
| 139 | + "notBefore": event.NotBefore, |
141 | 140 | }).Set(eventValue) |
142 | 141 | } |
143 | 142 | } else { |
144 | 143 | scheduledEvent.With( |
145 | 144 | prometheus.Labels{ |
146 | | - "eventID": event.EventId, |
147 | | - "eventType": event.EventType, |
| 145 | + "eventID": event.EventId, |
| 146 | + "eventType": event.EventType, |
148 | 147 | "resourceType": event.ResourceType, |
149 | | - "resource": "", |
150 | | - "eventStatus": event.EventStatus, |
151 | | - "notBefore": event.NotBefore, |
| 148 | + "resource": "", |
| 149 | + "eventStatus": event.EventStatus, |
| 150 | + "notBefore": event.NotBefore, |
152 | 151 | }).Set(eventValue) |
153 | 152 | } |
154 | 153 | } |
155 | 154 |
|
156 | 155 | scheduledEventDocumentIncarnation.With(prometheus.Labels{}).Set(float64(scheduledEvents.DocumentIncarnation)) |
157 | 156 |
|
158 | | - Logger.Verbose("Fetched %v Azure ScheduledEvents",len(scheduledEvents.Events)) |
| 157 | + Logger.Verbose("Fetched %v Azure ScheduledEvents", len(scheduledEvents.Events)) |
159 | 158 | } |
160 | 159 |
|
161 | 160 | func fetchApiUrl() (*AzureScheduledEventResponse, error) { |
|
0 commit comments