azuremonitor

package
v0.0.0-...-34a2968 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsightsMetricsResultToFrame

func InsightsMetricsResultToFrame(mr MetricsResult, metric, agg string, dimensions []string) (*data.Frame, error)

InsightsMetricsResultToFrame converts a MetricsResult (an Application Insights metrics query response) to a dataframe. Due to the dynamic nature of the MetricsResult object, the name of the metric, aggregation, and requested dimensions are used to determine the expected shape of the object. This builds all series into a single data.Frame with one time index (a wide formatted time series frame).

func KqlInterpolate

func KqlInterpolate(query *tsdb.Query, timeRange *tsdb.TimeRange, kql string, defaultTimeField ...string) (string, error)

KqlInterpolate interpolates macros for Kusto Query Language (KQL) queries

func LogTableToFrame

func LogTableToFrame(table *AzureLogAnalyticsTable) (*data.Frame, error)

LogTableToFrame converts an AzureLogAnalyticsTable to a data.Frame.

func NewAzureMonitorExecutor

func NewAzureMonitorExecutor(dsInfo *models.DataSource) (tsdb.TsdbQueryEndpoint, error)

NewAzureMonitorExecutor initializes a http client

Types

type ApplicationInsightsDatasource

type ApplicationInsightsDatasource struct {
	// contains filtered or unexported fields
}

ApplicationInsightsDatasource calls the application insights query API.

type ApplicationInsightsQuery

type ApplicationInsightsQuery struct {
	RefID string

	// Text based raw query options.
	ApiURL string
	Params url.Values
	Alias  string
	Target string
	// contains filtered or unexported fields
}

ApplicationInsightsQuery is the model that holds the information needed to make a metrics query to Application Insights, and the information used to parse the response.

type ApplicationInsightsQueryResponse

type ApplicationInsightsQueryResponse struct {
	Tables []struct {
		Name    string `json:"name"`
		Columns []struct {
			Name string `json:"name"`
			Type string `json:"type"`
		} `json:"columns"`
		Rows [][]interface{} `json:"rows"`
	} `json:"tables"`
}

ApplicationInsightsQueryResponse is the json response from the Application Insights API

type AzureLogAnalyticsDatasource

type AzureLogAnalyticsDatasource struct {
	// contains filtered or unexported fields
}

AzureLogAnalyticsDatasource calls the Azure Log Analytics API's

type AzureLogAnalyticsQuery

type AzureLogAnalyticsQuery struct {
	RefID        string
	ResultFormat string
	URL          string
	Model        *simplejson.Json
	Params       url.Values
	Target       string
}

AzureLogAnalyticsQuery is the query request that is built from the saved values for from the UI

type AzureLogAnalyticsResponse

type AzureLogAnalyticsResponse struct {
	Tables []AzureLogAnalyticsTable `json:"tables"`
}

AzureLogAnalyticsResponse is the json response object from the Azure Log Analytics API.

func (*AzureLogAnalyticsResponse) GetPrimaryResultTable

func (ar *AzureLogAnalyticsResponse) GetPrimaryResultTable() (*AzureLogAnalyticsTable, error)

GetPrimaryResultTable returns the first table in the response named "PrimaryResult", or an error if there is no table by that name.

type AzureLogAnalyticsTable

type AzureLogAnalyticsTable struct {
	Name    string `json:"name"`
	Columns []struct {
		Name string `json:"name"`
		Type string `json:"type"`
	} `json:"columns"`
	Rows [][]interface{} `json:"rows"`
}

AzureLogAnalyticsTable is the table format for Log Analytics responses

type AzureMonitorDatasource

type AzureMonitorDatasource struct {
	// contains filtered or unexported fields
}

AzureMonitorDatasource calls the Azure Monitor API - one of the four API's supported

type AzureMonitorExecutor

type AzureMonitorExecutor struct {
	// contains filtered or unexported fields
}

AzureMonitorExecutor executes queries for the Azure Monitor datasource - all four services

func (*AzureMonitorExecutor) Query

func (e *AzureMonitorExecutor) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error)

Query takes in the frontend queries, parses them into the query format expected by chosen Azure Monitor service (Azure Monitor, App Insights etc.) executes the queries against the API and parses the response into the right format

type AzureMonitorQuery

type AzureMonitorQuery struct {
	URL           string
	UrlComponents map[string]string
	Target        string
	Params        url.Values
	RefID         string
	Alias         string
}

AzureMonitorQuery is the query for all the services as they have similar queries with a url, a querystring and an alias field

type AzureMonitorResponse

type AzureMonitorResponse struct {
	Cost     int    `json:"cost"`
	Timespan string `json:"timespan"`
	Interval string `json:"interval"`
	Value    []struct {
		ID   string `json:"id"`
		Type string `json:"type"`
		Name struct {
			Value          string `json:"value"`
			LocalizedValue string `json:"localizedValue"`
		} `json:"name"`
		Unit       string `json:"unit"`
		Timeseries []struct {
			Metadatavalues []struct {
				Name struct {
					Value          string `json:"value"`
					LocalizedValue string `json:"localizedValue"`
				} `json:"name"`
				Value string `json:"value"`
			} `json:"metadatavalues"`
			Data []struct {
				TimeStamp time.Time `json:"timeStamp"`
				Average   float64   `json:"average,omitempty"`
				Total     float64   `json:"total,omitempty"`
				Count     float64   `json:"count,omitempty"`
				Maximum   float64   `json:"maximum,omitempty"`
				Minimum   float64   `json:"minimum,omitempty"`
			} `json:"data"`
		} `json:"timeseries"`
	} `json:"value"`
	Namespace      string `json:"namespace"`
	Resourceregion string `json:"resourceregion"`
}

AzureMonitorResponse is the json response from the Azure Monitor API

type InsightsAnalyticsDatasource

type InsightsAnalyticsDatasource struct {
	// contains filtered or unexported fields
}

type InsightsAnalyticsQuery

type InsightsAnalyticsQuery struct {
	RefID string

	RawQuery          string
	InterpolatedQuery string

	ResultFormat string

	Params url.Values
	Target string
}

type InsightsDimensions

type InsightsDimensions []string

InsightsDimensions will unmarshal from a JSON string, or an array of strings, into a string array. This exists to support an older query format which is updated when a user saves the query or it is sent from the front end, but may not be when alerting fetches the model.

func (*InsightsDimensions) UnmarshalJSON

func (s *InsightsDimensions) UnmarshalJSON(data []byte) error

UnmarshalJSON fulfills the json.Unmarshaler interface type.

type LogAnalyticsMeta

type LogAnalyticsMeta struct {
	ColumnTypes  []string `json:"azureColumnTypes"`
	Subscription string   `json:"subscription"`
	Workspace    string   `json:"workspace"`
	EncodedQuery []byte   `json:"encodedQuery"` // EncodedQuery is used for deep links.
}

LogAnalyticsMeta is a type for the a Frame's Meta's Custom property.

type MetricsResult

type MetricsResult struct {
	Value *MetricsResultInfo `json:"value,omitempty"`
}

MetricsResult a metric result. This is copied from azure-sdk-for-go/services/preview/appinsights/v1/insights.

type MetricsResultInfo

type MetricsResultInfo struct {
	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
	AdditionalProperties map[string]interface{} `json:""`
	// Start - Start time of the metric.
	Start time.Time `json:"start,omitempty"`
	// End - Start time of the metric.
	End time.Time `json:"end,omitempty"`
	// Interval - The interval used to segment the metric data.
	Interval *string `json:"interval,omitempty"`
	// Segments - Segmented metric data (if segmented).
	Segments *[]MetricsSegmentInfo `json:"segments,omitempty"`
}

MetricsResultInfo a metric result data. This is copied from azure-sdk-for-go/services/preview/appinsights/v1/insights (except time Type is changed).

func (*MetricsResultInfo) UnmarshalJSON

func (mri *MetricsResultInfo) UnmarshalJSON(body []byte) error

UnmarshalJSON is the custom unmarshaler for MetricsResultInfo struct. This is copied from azure-sdk-for-go/services/preview/appinsights/v1/insights (except time Type is changed).

type MetricsSegmentInfo

type MetricsSegmentInfo struct {
	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
	AdditionalProperties map[string]interface{} `json:""`
	// Start - Start time of the metric segment (only when an interval was specified).
	Start time.Time `json:"start,omitempty"`
	// End - Start time of the metric segment (only when an interval was specified).
	End time.Time `json:"end,omitempty"`
	// Segments - Segmented metric data (if further segmented).
	Segments *[]MetricsSegmentInfo `json:"segments,omitempty"`
}

MetricsSegmentInfo is a metric segment. This is copied from azure-sdk-for-go/services/preview/appinsights/v1/insights (except time Type is changed).

func (*MetricsSegmentInfo) UnmarshalJSON

func (mri *MetricsSegmentInfo) UnmarshalJSON(body []byte) error

UnmarshalJSON is the custom unmarshaler for MetricsSegmentInfo struct. This is copied from azure-sdk-for-go/services/preview/appinsights/v1/insights (except time Type is changed).

type TimeGrain

type TimeGrain struct{}

TimeGrain handles conversions between the ISO 8601 Duration format (PT1H), Kbn units (1h) and Time Grains (1 hour) Also handles using the automatic Grafana interval to calculate a ISO 8601 Duration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL