Skip to content

Commit

Permalink
feat(prometheus): Minor cleanup relating to K8S support. (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Duftler committed Mar 12, 2018
1 parent 195cd27 commit d82dba0
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
40 changes: 40 additions & 0 deletions json-formats.md
Expand Up @@ -128,6 +128,46 @@ Atlas, Stackdriver and Prometheus are used.
}
}
```
```JSON
{
"name": "MySampleK8SPrometheusCanaryConfigWithCustomFilterTemplate",
"description": "Example Kayenta Configuration with Custom Filter Template using Prometheus for K8S",
"configVersion": "1.0",
"applications": [
"myapp"
],
"judge": {
"name": "dredd-v1.0",
"judgeConfigurations": { }
},
"metrics": [
{
"name": "cpu_usage_seconds",
"query": {
"type": "prometheus",
"metricName": "container_cpu_usage_seconds_total",
"labelBindings": [ ],
"customFilterTemplate": "my-template"
},
"groups": ["system"],
"analysisConfigurations": { },
"scopeName": "default"
}
],
"templates": {
"my-template": "container_name='${container_name}'"
},
"classifier": {
"groupWeights": {
"system": 100.0
},
"scoreThresholds": {
"pass": 95.0,
"marginal": 75.0
}
}
}
```
## Canary Data Archival Format

This format is used to store the results from a specific canary run.
Expand Down
Expand Up @@ -92,6 +92,14 @@ public Map queryMetrics(@RequestParam(required = false) final String metricsAcco
start = determineDefaultProperty(start, "start", prometheusConfigurationTestControllerDefaultProperties);
end = determineDefaultProperty(end, "end", prometheusConfigurationTestControllerDefaultProperties);

if (StringUtils.isEmpty(start)) {
throw new IllegalArgumentException("Start time is required.");
}

if (StringUtils.isEmpty(end)) {
throw new IllegalArgumentException("End time is required.");
}

String resolvedMetricsAccountName = CredentialsHelper.resolveAccountByNameOrType(metricsAccountName,
AccountCredentials.Type.METRICS_STORE,
accountCredentialsRepository);
Expand Down
Expand Up @@ -105,9 +105,10 @@ private StringBuilder addScopeFilter(StringBuilder queryBuilder,
} else if ("aws_ec2_instance".equals(resourceType)) {
addEC2Filters("asg_groupName", scope, region, filters);
} else {
log.warn("There is no explicit support for resourceType '" + resourceType + "'. Your mileage may vary.");
throw new IllegalArgumentException("There is no explicit support for resourceType '" + resourceType + "'. " +
"You may build whatever query makes sense for your environment via label " +
"bindings and custom filter templates.");
}
// TODO(duftler): Add support for K8S resource types.
} else {
List<String> customFilterTokens = Arrays.asList(customFilter.split(","));

Expand Down
Expand Up @@ -95,6 +95,14 @@ public Map queryMetrics(@RequestParam(required = false) final String metricsAcco
startTimeIso = determineDefaultProperty(startTimeIso, "start", stackdriverConfigurationTestControllerDefaultProperties);
endTimeIso = determineDefaultProperty(endTimeIso, "end", stackdriverConfigurationTestControllerDefaultProperties);

if (StringUtils.isEmpty(startTimeIso)) {
throw new IllegalArgumentException("Start time is required.");
}

if (StringUtils.isEmpty(endTimeIso)) {
throw new IllegalArgumentException("End time is required.");
}

String resolvedMetricsAccountName = CredentialsHelper.resolveAccountByNameOrType(metricsAccountName,
AccountCredentials.Type.METRICS_STORE,
accountCredentialsRepository);
Expand Down

0 comments on commit d82dba0

Please sign in to comment.