diff --git a/README.md b/README.md index a75383d..91ccd27 100644 --- a/README.md +++ b/README.md @@ -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: ``` @@ -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 ``` diff --git a/probe.go b/probe.go index 2c80ee7..7dfec5a 100644 --- a/probe.go +++ b/probe.go @@ -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...) + } } } }