@@ -12,12 +12,11 @@ import (
12
12
log "github.com/sirupsen/logrus"
13
13
"github.com/webdevops/azure-resourcegraph-exporter/kusto"
14
14
"net/http"
15
- "strconv"
16
15
"time"
17
16
)
18
17
19
18
const (
20
- RESOURCEGRAPH_QUERY_OPTIONS_TOP = 1000
19
+ OPINSIGHTS_URL_SUFFIX = "/v1"
21
20
)
22
21
23
22
func handleProbeRequest (w http.ResponseWriter , r * http.Request ) {
@@ -44,14 +43,8 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
44
43
45
44
ctx := context .Background ()
46
45
47
- defaultSubscriptions := []string {}
48
- for _ , subscription := range AzureSubscriptions {
49
- defaultSubscriptions = append (defaultSubscriptions , * subscription .SubscriptionID )
50
- }
51
-
52
- // Create and authorize a ResourceGraph client
53
- // queryClient := operationalinsights.NewQueryClientWithBaseURI(AzureEnvironment.ResourceIdentifiers.OperationalInsights + "/v1/")
54
- queryClient := operationalinsights .NewQueryClient ()
46
+ // Create and authorize a operationalinsights client
47
+ queryClient := operationalinsights .NewQueryClientWithBaseURI (AzureEnvironment .ResourceIdentifiers .OperationalInsights + OPINSIGHTS_URL_SUFFIX )
55
48
queryClient .Authorizer = OpInsightsAuthorizer
56
49
queryClient .ResponseInspector = respondDecorator ()
57
50
@@ -83,7 +76,6 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
83
76
}
84
77
startTime := time .Now ()
85
78
86
-
87
79
contextLogger := probeLogger .WithField ("metric" , queryConfig .Metric )
88
80
89
81
if queryConfig .Timespan == nil {
@@ -100,8 +92,8 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
100
92
// Set options
101
93
workspaces := []string {}
102
94
queryBody := operationalinsights.QueryBody {
103
- Query : & queryConfig .Query ,
104
- Timespan : queryConfig .Timespan ,
95
+ Query : & queryConfig .Query ,
96
+ Timespan : queryConfig .Timespan ,
105
97
Workspaces : & workspaces ,
106
98
}
107
99
@@ -115,7 +107,7 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
115
107
contextLogger .Debug ("parsing result" )
116
108
resultTables := * results .Tables
117
109
118
- if resultTables != nil && len (resultTables ) == 1 {
110
+ if len (resultTables ) == 1 {
119
111
for _ , v := range * resultTables [0 ].Rows {
120
112
resultTotalRecords ++
121
113
resultRow := map [string ]interface {}{}
@@ -126,7 +118,7 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
126
118
127
119
for metricName , metric := range kusto .BuildPrometheusMetricList (queryConfig .Metric , queryConfig .MetricConfig , resultRow ) {
128
120
// inject workspaceId
129
- for num , _ := range metric {
121
+ for num := range metric {
130
122
metric [num ].Labels ["workspaceId" ] = workspaceId
131
123
}
132
124
@@ -188,10 +180,6 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
188
180
func respondDecorator () autorest.RespondDecorator {
189
181
return func (p autorest.Responder ) autorest.Responder {
190
182
return autorest .ResponderFunc (func (r * http.Response ) error {
191
- ratelimit := r .Header .Get ("x-ms-user-quota-remaining" )
192
- if v , err := strconv .ParseInt (ratelimit , 10 , 64 ); err == nil {
193
- prometheusRateLimit .WithLabelValues ().Set (float64 (v ))
194
- }
195
183
return nil
196
184
})
197
185
}
0 commit comments