Skip to content

Commit

Permalink
implement full table support
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Blaschke <[email protected]>
  • Loading branch information
mblaschke committed May 5, 2021
1 parent 7257726 commit bddf06f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Global metrics
Example
-------

for examples of result processing can be found within [azure-resourcegraph-expoter](https://github.com/webdevops/azure-resourcegraph-exporter) (uses same processing library)
more examples of result processing can be found within [azure-resourcegraph-expoter](https://github.com/webdevops/azure-resourcegraph-exporter) (uses same processing library)

Config file:
```
Expand All @@ -76,5 +76,5 @@ Metrics:
```
# HELP azure_loganalytics_operationstatus_count azure_loganalytics_operationstatus_count
# TYPE azure_loganalytics_operationstatus_count gauge
azure_loganalytics_operationstatus_count{OperationStatus="Succeeded",workspaceId="xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"} 1
azure_loganalytics_operationstatus_count{OperationStatus="Succeeded",workspaceId="xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx",workspaceTable="PrimaryResult"} 1
```
32 changes: 20 additions & 12 deletions probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,30 @@ func handleProbeRequest(w http.ResponseWriter, r *http.Request) {
contextLogger.Debug("parsing result")
resultTables := *results.Tables

if len(resultTables) == 1 {
for _, v := range *resultTables[0].Rows {
resultTotalRecords++
resultRow := map[string]interface{}{}

for colNum, colName := range *resultTables[0].Columns {
resultRow[to.String(colName.Name)] = v[colNum]
if len(resultTables) >= 1 {
for _, table := range resultTables {
if table.Rows == nil || table.Columns == nil {
// no results found, skip table
continue
}

for metricName, metric := range kusto.BuildPrometheusMetricList(queryConfig.Metric, queryConfig.MetricConfig, resultRow) {
// inject workspaceId
for num := range metric {
metric[num].Labels["workspaceId"] = workspaceId
for _, v := range *table.Rows {
resultTotalRecords++
resultRow := map[string]interface{}{}

for colNum, colName := range *resultTables[0].Columns {
resultRow[to.String(colName.Name)] = v[colNum]
}

metricList.Add(metricName, metric...)
for metricName, metric := range kusto.BuildPrometheusMetricList(queryConfig.Metric, queryConfig.MetricConfig, resultRow) {
// inject workspaceId
for num := range metric {
metric[num].Labels["workspaceTable"] = to.String(table.Name)
metric[num].Labels["workspaceId"] = workspaceId
}

metricList.Add(metricName, metric...)
}
}
}
}
Expand Down

0 comments on commit bddf06f

Please sign in to comment.