Documentation ¶
Index ¶
- Constants
- func IsHttpSSLVerificationEnabled() bool
- func IsValidUUID(uuid string) bool
- type ChartSeries
- type DTUSQLResult
- type DataExplorerQuery
- type DtEnvAPIv2Error
- type DynatraceDashboard
- type DynatraceDashboards
- type DynatraceMetricsQueryResult
- type DynatraceProblem
- type DynatraceProblemQueryResult
- type DynatraceSLOResult
- type DynatraceSecurityProblem
- type DynatraceSecurityProblemQueryResult
- type Handler
- func (ph *Handler) BuildDynatraceMetricsQuery(metricquery string, startUnix time.Time, endUnix time.Time) (string, string, error)
- func (ph *Handler) BuildDynatraceUSQLQuery(query string, startUnix time.Time, endUnix time.Time) string
- func (ph *Handler) ExecuteGetDynatraceProblemById(problemId string) (*DynatraceProblem, error)
- func (ph *Handler) ExecuteGetDynatraceProblems(problemQuery string, startUnix time.Time, endUnix time.Time) (*DynatraceProblemQueryResult, error)
- func (ph *Handler) ExecuteGetDynatraceSLO(sloID string, startUnix time.Time, endUnix time.Time) (*DynatraceSLOResult, error)
- func (ph *Handler) ExecuteGetDynatraceSecurityProblems(problemQuery string, startUnix time.Time, endUnix time.Time) (*DynatraceSecurityProblemQueryResult, error)
- func (ph *Handler) ExecuteMetricAPIDescribe(metricID string) (*MetricDefinition, error)
- func (ph *Handler) ExecuteMetricsAPIQuery(metricsQuery string) (*DynatraceMetricsQueryResult, error)
- func (ph *Handler) ExecuteUSQLQuery(usql string) (*DTUSQLResult, error)
- func (ph *Handler) GenerateMetricQueryFromChart(series ChartSeries, tileManagementZoneFilter string, ...) (string, string, string, string, string, string, error)
- func (ph *Handler) GenerateMetricQueryFromDataExplorer(dataQuery DataExplorerQuery, tileManagementZoneFilter string, ...) (string, string, string, string, string, string, error)
- func (ph *Handler) GenerateSLISLOFromMetricsAPIQuery(noOfDimensionsInChart int, baseIndicatorName string, ...) []*keptnv2.SLIResult
- func (ph *Handler) GetEntitySelectorFromEntityFilter(filtersPerEntityType map[string]map[string][]string, entityType string) string
- func (ph *Handler) GetSLIValue(metric string, startUnix time.Time, endUnix time.Time) (float64, error)
- func (ph *Handler) HasDashboardChanged(keptnEvent *common.BaseKeptnEvent, dashboardJSON *DynatraceDashboard, ...) bool
- func (ph *Handler) ProcessOpenProblemTile(problemSelector string, entitySelector string, startUnix time.Time, ...) (*keptnv2.SLIResult, string, string, *keptncommon.SLO, error)
- func (ph *Handler) ProcessOpenSecurityProblemTile(securityProblemSelector string, startUnix time.Time, endUnix time.Time) (*keptnv2.SLIResult, string, string, *keptncommon.SLO, error)
- func (ph *Handler) ProcessSLOTile(sloID string, startUnix time.Time, endUnix time.Time) (*keptnv2.SLIResult, string, string, *keptncommon.SLO, error)
- func (ph *Handler) QueryDynatraceDashboardForSLIs(keptnEvent *common.BaseKeptnEvent, dashboard string, startUnix time.Time, ...) (string, *DynatraceDashboard, *SLI, *keptncommon.ServiceLevelObjectives, ...)
- type MetricDefinition
- type MetricQueryResultNumbers
- type MetricQueryResultValues
- type NestedFilterDataExplorer
- type SLI
Constants ¶
const ErrorRate = "error_rate"
const MetricsAPIOldFormatNewFormatDoc = "https://github.com/keptn-contrib/dynatrace-sli-service/blob/master/docs/CustomQueryFormatMigration.md"
store url to the metrics api format migration document
const ResponseTimeP50 = "response_time_p50"
const ResponseTimeP90 = "response_time_p90"
const ResponseTimeP95 = "response_time_p95"
const Throughput = "throughput"
Variables ¶
This section is empty.
Functions ¶
func IsHttpSSLVerificationEnabled ¶
func IsHttpSSLVerificationEnabled() bool
IsHttpSSLVerificationEnabled returns whether the SSL verification is enabled or disabled
Types ¶
type ChartSeries ¶
type ChartSeries struct { Metric string `json:"metric"` Aggregation string `json:"aggregation"` Percentile interface{} `json:"percentile"` Type string `json:"type"` EntityType string `json:"entityType"` Dimensions []struct { ID string `json:"id"` Name string `json:"name"` Values []string `json:"values"` EntityDimension bool `json:"entitiyDimension"` } `json:"dimensions"` SortAscending bool `json:"sortAscending"` SortColumn bool `json:"sortColumn"` AggregationRate string `json:"aggregationRate"` }
Chart Series for a regular Chart
type DTUSQLResult ¶
type DTUSQLResult struct { ExtrapolationLevel int `json:"extrapolationLevel"` ColumnNames []string `json:"columnNames"` Values [][]interface{} `json:"values"` }
DTUSQLResult struct
type DataExplorerQuery ¶
type DataExplorerQuery struct { ID string `json:"id"` Metric string `json:"metric"` SpaceAggregation string `json:"spaceAggregation"` TimeAggregation string `json:"timeAggregation"` SplitBy []string `json:"splitBy"` FilterBy *struct { FilterOperator string `json:"filterOperator"` NestedFilters []NestedFilterDataExplorer `json:"nestedFilters"` Criteria []struct { Value string `json:"value"` Evaluator string `json:"evaluator"` } `json:"criteria"` } `json:"filterBy,omitempty"` }
Query Definition for DATA_EXPLORER dashboard tile
type DtEnvAPIv2Error ¶
type DtEnvAPIv2Error struct { Error struct { Code int `json:"code"` Message string `json:"message"` ConstraintViolations []struct { Path string `json:"path"` Message string `json:"message"` ParameterLocation string `json:"parameterLocation"` Location string `json:"location"` } `json:"constraintViolations"` } `json:"error"` }
type DynatraceDashboard ¶
type DynatraceDashboard struct { Metadata struct { ConfigurationVersions []int `json:"configurationVersions"` ClusterVersion string `json:"clusterVersion"` } `json:"metadata"` ID string `json:"id"` DashboardMetadata struct { Name string `json:"name"` Shared bool `json:"shared"` Owner string `json:"owner"` SharingDetails struct { LinkShared bool `json:"linkShared"` Published bool `json:"published"` } `json:"sharingDetails"` DashboardFilter *struct { Timeframe string `json:"timeframe"` ManagementZone *struct { ID string `json:"id"` Name string `json:"name"` } `json:"managementZone,omitempty"` } `json:"dashboardFilter,omitempty"` Tags []string `json:"tags"` } `json:"dashboardMetadata"` Tiles []struct { Name string `json:"name"` TileType string `json:"tileType"` Configured bool `json:"configured"` Query string `json:"query"` Type string `json:"type"` CustomName string `json:"customName` Markdown string `json:"markdown` Bounds struct { Top int `json:"top"` Left int `json:"left"` Width int `json:"width"` Height int `json:"height"` } `json:"bounds"` TileFilter struct { Timeframe string `json:"timeframe"` ManagementZone *struct { ID string `json:"id"` Name string `json:"name"` } `json:"managementZone,omitempty"` } `json:"tileFilter"` Queries []DataExplorerQuery `json:"queries"` AssignedEntities []string `json:"assignedEntities"` FilterConfig struct { Type string `json:"type"` CustomName string `json:"customName"` DefaultName string `json:"defaultName"` ChartConfig struct { LegendShown bool `json:"legendShown"` Type string `json:"type"` Series []ChartSeries `json:"series"` ResultMetadata struct { } `json:"resultMetadata"` } `json:"chartConfig"` FiltersPerEntityType map[string]map[string][]string `json:"filtersPerEntityType"` } `json:"filterConfig"` } `json:"tiles"` }
DynatraceDashboard is struct for /dashboards/<dashboardID> endpoint
type DynatraceDashboards ¶
type DynatraceDashboards struct { Dashboards []struct { ID string `json:"id"` Name string `json:"name"` Owner string `json:"owner"` } `json:"dashboards"` }
DynatraceDashboards is struct for /dashboards endpoint
type DynatraceMetricsQueryResult ¶
type DynatraceMetricsQueryResult struct { TotalCount int `json:"totalCount"` NextPageKey string `json:"nextPageKey"` Result []MetricQueryResultValues `json:"result"` }
DynatraceMetricsQueryResult is struct for /metrics/query
type DynatraceProblem ¶
type DynatraceProblem struct { ProblemID string `json:"problemId"` DisplayID string `json:"displayId"` Title string `json:"title"` ImpactLevel string `json:"impactLevel"` SeverityLevel string `json:"severityLevel"` Status string `json:"status"` AffectedEntities []struct { EntityID struct { ID string `json:"id"` Type string `json:"type"` } `json:"entityId"` Name string `json:"name"` } `json:"affectedEntities"` ImpactedEntities []struct { EntityID struct { ID string `json:"id"` Type string `json:"type"` } `json:"entityId"` Name string `json:"name"` } `json:"impactedEntities"` RootCauseEntity struct { EntityID struct { ID string `json:"id"` Type string `json:"type"` } `json:"entityId"` Name string `json:"name"` } `json:"rootCauseEntity"` ManagementZones []interface{} `json:"managementZones"` EntityTags []struct { Context string `json:"context"` Key string `json:"key"` Value string `json:"value"` StringRepresentation string `json:"stringRepresentation"` } `json:"entityTags"` ProblemFilters []struct { ID string `json:"id"` Name string `json:"name"` } `json:"problemFilters"` StartTime int64 `json:"startTime"` EndTime int64 `json:"endTime"` }
Problem Detail returned by /api/v2/problems
type DynatraceProblemQueryResult ¶
type DynatraceProblemQueryResult struct { TotalCount int `json:"totalCount"` PageSize int `json:"pageSize"` Problems []DynatraceProblem `json:"problems"` }
Result of /api/v1/problems
type DynatraceSLOResult ¶
type DynatraceSLOResult struct { ID string `json:"id"` Enabled bool `json:"enabled"` Name string `json:"name"` Description string `json:"description"` EvaluatedPercentage float64 `json:"evaluatedPercentage"` ErrorBudget float64 `json:"errorBudget"` Status string `json:"status"` Error string `json:"error"` UseRateMetric bool `json:"useRateMetric"` MetricRate string `json:"metricRate"` MetricNumerator string `json:"metricNumerator"` MetricDenominator string `json:"metricDenominator"` TargetSuccessOLD float64 `json:"targetSuccess"` TargetWarningOLD float64 `json:"targetWarning"` Target float64 `json:"target"` Warning float64 `json:"warning"` EvaluationType string `json:"evaluationType"` TimeWindow string `json:"timeWindow"` Filter string `json:"filter"` }
type DynatraceSecurityProblem ¶
type DynatraceSecurityProblem struct { SecurityProblemID string `json:"securityProblemId"` DisplayID int `json:"displayId"` State string `json:"state"` VulnerabilityID string `json:"vulnerabilityId"` VulnerabilityType string `json:"vulnerabilityType"` FirstSeenTimestamp int `json:"firstSeenTimestamp"` LastUpdatedTimestamp int `json:"lastUpdatedTimestamp"` RiskAssessment struct { RiskCategory string `json:"riskCategory"` RiskScore struct { Value int `json:"value"` } `json:"riskScore"` Exposed bool `json:"exposed"` SensitiveDataAffected bool `json:"sensitiveDataAffected"` PublicExploitAvailable bool `json:"publicExploitAvailable"` } `json:"riskAssessment"` ManagementZones []string `json:"managementZones"` VulnerableComponents []struct { ID string `json:"id"` DisplayName string `json:"displayName"` FileName string `json:"fileName"` NumberOfVulnerableProcesses int `json:"numberOfVulnerableProcesses"` VulnerableProcesses []string `json:"vulnerableProcesses"` } `json:"vulnerableComponents"` VulnerableEntities []string `json:"vulnerableEntities"` ExposedEntities []string `json:"exposedEntities"` SensitiveDataAssets []string `json:"sensitiveDataAssets"` AffectedEntities struct { Applications []struct { ID string `json:"id"` NumberOfVulnerableProcesses int `json:"numberOfVulnerableProcesses"` VulnerableProcesses []string `json:"vulnerableProcesses"` } `json:"applications"` Services []struct { ID string `json:"id"` NumberOfVulnerableProcesses int `json:"numberOfVulnerableProcesses"` VulnerableProcesses []string `json:"vulnerableProcesses"` } `json:"services"` Hosts []struct { ID string `json:"id"` NumberOfVulnerableProcesses int `json:"numberOfVulnerableProcesses"` VulnerableProcesses []string `json:"vulnerableProcesses"` } `json:"hosts"` Databases []string `json:"databases"` } `json:"affectedEntities"` }
Problem Detail returned by /api/v2/securityProblems
type DynatraceSecurityProblemQueryResult ¶
type DynatraceSecurityProblemQueryResult struct { TotalCount int `json:"totalCount"` PageSize int `json:"pageSize"` NextPageKey string `json:"nextPageKey"` SecurityProblems []DynatraceSecurityProblem `json:"securityProblems"` }
Result of/api/v2/securityProblems
type Handler ¶
type Handler struct { ApiURL string Username string Password string KeptnEvent *common.BaseKeptnEvent HTTPClient *http.Client Headers map[string]string CustomQueries map[string]string CustomFilters []*keptnv2.SLIFilter }
Handler interacts with a dynatrace API endpoint
func NewDynatraceHandler ¶
func NewDynatraceHandler(apiURL string, keptnEvent *common.BaseKeptnEvent, headers map[string]string, customFilters []*keptnv2.SLIFilter, keptnContext string, eventID string) *Handler
NewDynatraceHandler returns a new dynatrace handler that interacts with the Dynatrace REST API
func (*Handler) BuildDynatraceMetricsQuery ¶
func (ph *Handler) BuildDynatraceMetricsQuery(metricquery string, startUnix time.Time, endUnix time.Time) (string, string, error)
BuildDynatraceMetricsQuery builds the complete query string based on start, end and filters metricQuery should contain metricSelector and entitySelector Returns:
#1: Finalized Dynatrace API Query #2: MetricID that this query will return, e.g: builtin:host.cpu #3: error
func (*Handler) BuildDynatraceUSQLQuery ¶
func (ph *Handler) BuildDynatraceUSQLQuery(query string, startUnix time.Time, endUnix time.Time) string
BuildDynatraceUSQLQuery builds a USQL query based on the incoming values
func (*Handler) ExecuteGetDynatraceProblemById ¶
func (ph *Handler) ExecuteGetDynatraceProblemById(problemId string) (*DynatraceProblem, error)
*
- ExecuteGetProblem
- Calls the /problems/<problemId> API call to retrieve Problem Details
func (*Handler) ExecuteGetDynatraceProblems ¶
func (ph *Handler) ExecuteGetDynatraceProblems(problemQuery string, startUnix time.Time, endUnix time.Time) (*DynatraceProblemQueryResult, error)
*
- ExecuteGetDynatraceProblems
- Calls the /problems/ API call to retrieve the the list of problems for that timeframe
- If successful returns the DynatraceProblemQueryResult object
func (*Handler) ExecuteGetDynatraceSLO ¶
func (ph *Handler) ExecuteGetDynatraceSLO(sloID string, startUnix time.Time, endUnix time.Time) (*DynatraceSLOResult, error)
*
- ExecuteGetDynatraceSLO
- Calls the /slo/{sloId} API call to retrieve the values of the Dynatrace SLO for that timeframe
- If successful returns the DynatraceSLOResult object
func (*Handler) ExecuteGetDynatraceSecurityProblems ¶
func (ph *Handler) ExecuteGetDynatraceSecurityProblems(problemQuery string, startUnix time.Time, endUnix time.Time) (*DynatraceSecurityProblemQueryResult, error)
*
- ExecuteGetDynatraceSecurityProblems
- Calls the /securityProblems/ API call to retrieve the list of security problems for that timeframe
- If successful returns the DynatraceSecurityProblemQueryResult object
func (*Handler) ExecuteMetricAPIDescribe ¶
func (ph *Handler) ExecuteMetricAPIDescribe(metricID string) (*MetricDefinition, error)
*
- ExecuteMetricAPIDescribe
- Calls the /metrics/<metricID> API call to retrieve Metric Definition Details
func (*Handler) ExecuteMetricsAPIQuery ¶
func (ph *Handler) ExecuteMetricsAPIQuery(metricsQuery string) (*DynatraceMetricsQueryResult, error)
ExecuteMetricsAPIQuery executes the passed Metrics API Call, validates that the call returns data and returns the data set
func (*Handler) ExecuteUSQLQuery ¶
func (ph *Handler) ExecuteUSQLQuery(usql string) (*DTUSQLResult, error)
ExecuteUSQLQuery executes the passed Metrics API Call, validates that the call returns data and returns the data set
func (*Handler) GenerateMetricQueryFromChart ¶
func (ph *Handler) GenerateMetricQueryFromChart(series ChartSeries, tileManagementZoneFilter string, filtersPerEntityType map[string]map[string][]string, startUnix time.Time, endUnix time.Time) (string, string, string, string, string, string, error)
*
- Looks at the ChartSeries configuration of a regular chart and generates the Metrics Query
- Returns
- #1: metricId, e.g: built-in:mymetric
- #2: metricUnit, e.g: MilliSeconds
- #3: metricQuery, e.g: metricSelector=metric&filter...
- #4: fullMetricQuery, e.g: metricQuery&from=123213&to=2323
- #5: entitySelectirSLIDefinition, e.g: ,entityid(FILTERDIMENSIONVALUE)
- #6: filterSLIDefinitionAttregator, e.g: , filter(eq(Test Step,FILTERDIMENSIONVALUE))
func (*Handler) GenerateMetricQueryFromDataExplorer ¶
func (ph *Handler) GenerateMetricQueryFromDataExplorer(dataQuery DataExplorerQuery, tileManagementZoneFilter string, startUnix time.Time, endUnix time.Time) (string, string, string, string, string, string, error)
*
- Looks at the DataExplorerQuery configuration of a data explorer chart and generates the Metrics Query
- Returns
- #1: metricId, e.g: built-in:mymetric
- #2: metricUnit, e.g: MilliSeconds
- #3: metricQuery, e.g: metricSelector=metric&filter...
- #4: fullMetricQuery, e.g: metricQuery&from=123213&to=2323
- #5: entitySelectirSLIDefinition, e.g: ,entityid(FILTERDIMENSIONVALUE)
- #6: filterSLIDefinitionAttregator, e.g: , filter(eq(Test Step,FILTERDIMENSIONVALUE))
func (*Handler) GenerateSLISLOFromMetricsAPIQuery ¶
func (ph *Handler) GenerateSLISLOFromMetricsAPIQuery(noOfDimensionsInChart int, baseIndicatorName string, passSLOs []*keptncommon.SLOCriteria, warningSLOs []*keptncommon.SLOCriteria, weight int, keySli bool, metricID string, metricUnit string, metricQuery string, fullMetricQuery string, filterSLIDefinitionAggregator string, entitySelectorSLIDefinition string, dashboardSLI *SLI, dashboardSLO *keptncommon.ServiceLevelObjectives) []*keptnv2.SLIResult
*
- Generates the relvant SLIs & SLO definitions based on the metric query
- noOfDimensionsInChart: how many dimensions did we have in the chart definition
func (*Handler) GetEntitySelectorFromEntityFilter ¶
func (ph *Handler) GetEntitySelectorFromEntityFilter(filtersPerEntityType map[string]map[string][]string, entityType string) string
*
- Parses the filtersPerEntityType dashboard definition and returns the entitySelector query filter - the return value always starts with a , (comma)
- return example: ,entityId("ABAD-222121321321")
func (*Handler) GetSLIValue ¶
func (ph *Handler) GetSLIValue(metric string, startUnix time.Time, endUnix time.Time) (float64, error)
*
- GetSLIValue queries a single metric value from Dynatrace API
- Can handle both Metric Queries as well as USQL
func (*Handler) HasDashboardChanged ¶
func (ph *Handler) HasDashboardChanged(keptnEvent *common.BaseKeptnEvent, dashboardJSON *DynatraceDashboard, existingDashboardContent string) bool
*
- This function will validate if the current dashboard.json stored in the configuration repo is the same as the one passed as parameter
func (*Handler) ProcessOpenProblemTile ¶
func (ph *Handler) ProcessOpenProblemTile(problemSelector string, entitySelector string, startUnix time.Time, endUnix time.Time) (*keptnv2.SLIResult, string, string, *keptncommon.SLO, error)
*
- Processes an Open Problem Tile and queries the number of open problems. The current default is that there is a pass criteria of <= 0 as we dont allow problems
- If successful returns sliResult, sliIndicatorName, sliQuery & sloDefinition
func (*Handler) ProcessOpenSecurityProblemTile ¶
func (ph *Handler) ProcessOpenSecurityProblemTile(securityProblemSelector string, startUnix time.Time, endUnix time.Time) (*keptnv2.SLIResult, string, string, *keptncommon.SLO, error)
*
- Processes an Open Problem Tile and queries the number of open problems. The current default is that there is a pass criteria of <= 0 as we dont allow problems
- If successful returns sliResult, sliIndicatorName, sliQuery & sloDefinition
func (*Handler) ProcessSLOTile ¶
func (ph *Handler) ProcessSLOTile(sloID string, startUnix time.Time, endUnix time.Time) (*keptnv2.SLIResult, string, string, *keptncommon.SLO, error)
*
- Processes an SLO Tile and queries the data from the Dynatrace API
- If successful returns sliResult, sliIndicatorName, sliQuery & sloDefinition
func (*Handler) QueryDynatraceDashboardForSLIs ¶
func (ph *Handler) QueryDynatraceDashboardForSLIs(keptnEvent *common.BaseKeptnEvent, dashboard string, startUnix time.Time, endUnix time.Time) (string, *DynatraceDashboard, *SLI, *keptncommon.ServiceLevelObjectives, []*keptnv2.SLIResult, error)
QueryDynatraceDashboardForSLIs implements - https://github.com/keptn-contrib/dynatrace-sli-service/issues/60 Queries Dynatrace for the existance of a dashboard tagged with keptn_project:project, keptn_stage:stage, keptn_service:service, SLI if this dashboard exists it will be parsed and a custom SLI_dashboard.yaml and an SLO_dashboard.yaml will be created Returns:
#1: Link to Dashboard #2: SLI #3: ServiceLevelObjectives #4: SLIResult #5: Error
type MetricDefinition ¶
type MetricDefinition struct { MetricID string `json:"metricId"` DisplayName string `json:"displayName"` Description string `json:"description"` Unit string `json:"unit"` AggregationTypes []string `json:"aggregationTypes"` Transformations []string `json:"transformations"` DefaultAggregation struct { Type string `json:"type"` } `json:"defaultAggregation"` DimensionDefinitions []struct { Name string `json:"name"` Type string `json:"type"` Key string `json:"key"` DisplayName string `json:"displayName"` } `json:"dimensionDefinitions"` EntityType []string `json:"entityType"` }
MetricDefinition defines the output of /metrics/<metricID>
type MetricQueryResultValues ¶
type MetricQueryResultValues struct { MetricID string `json:"metricId"` Data []MetricQueryResultNumbers `json:"data"` }
type NestedFilterDataExplorer ¶
type NestedFilterDataExplorer struct { Filter string `json:"filter"` FilterType string `json:"filterType"` FilterOperator string `json:"filterOperator"` NestedFilters []NestedFilterDataExplorer `json:"nestedFilters"` Criteria []struct { Value string `json:"value"` Evaluator string `json:"evaluator"` } `json:"criteria"` }