Skip to content

Commit

Permalink
feat(kayenta): allow more flexible queries in canary config (spinnake…
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmke authored and Matt Duftler committed Dec 28, 2018
1 parent c0bcdf4 commit 913841c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ public String buildQuery(String metricsAccountName, CanaryConfig canaryConfig, C
// Example for a query produced by this class:
// SELECT count(*) FROM Transaction TIMESERIES MAX SINCE 1540382125 UNTIL 1540392125
// WHERE appName LIKE 'PROD - Service' AND httpResponseCode >= '500'
StringBuilder query = new StringBuilder("SELECT ");

query.append(queryConfig.getSelect());
query.append(" FROM Transaction TIMESERIES ");
// we expect the full select statement to be in the config
StringBuilder query = new StringBuilder(queryConfig.getSelect());
query.append(" TIMESERIES ");

if (newRelicCanaryScope.getStep() == 0) {
query.append("MAX");
} else {
Expand Down
8 changes: 4 additions & 4 deletions scratch/newrelic_adhoc_canary.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"name": "errorRate",
"query": {
"type": "newrelic",
"select": "count(*)/uniqueCount(host)",
"select": "SELECT count(*)/uniqueCount(host) FROM Transaction",
"q": "httpResponseCode >= '500'"
},
"groups": ["err"],
Expand All @@ -26,7 +26,7 @@
"name": "transactionTime",
"query": {
"type": "newrelic",
"select": "average(totalTime*1000)"
"select": "SELECT average(totalTime*1000) FROM Transaction"
},
"groups": ["app"],
"analysisConfigurations": { },
Expand All @@ -50,7 +50,7 @@
"end": "",
"step": "1",
"extendedScopeParams": {
"_scope_key": "",
"_scope_key": "build_version",
"appName": "PROD - MyComponent"
}
},
Expand All @@ -61,7 +61,7 @@
"end": "",
"step": "1",
"extendedScopeParams": {
"_scope_key": "",
"_scope_key": "build_version",
"appName": "PROD - MyComponent"
}
}
Expand Down
6 changes: 3 additions & 3 deletions scratch/newrelic_canary_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "Apdex",
"query": {
"type": "newrelic",
"select": "apdex(duration, 0.2)"
"select": "SELECT apdex(duration, 0.2) FROM Transaction"
},
"groups": [
"apdex"
Expand Down Expand Up @@ -58,7 +58,7 @@
"name": "Error Rate",
"query": {
"type": "newrelic",
"select": "percentage(count(*), WHERE error IS true)"
"select": "SELECT percentage(count(*), WHERE error IS true) FROM Transaction"
},
"groups": [
"err"
Expand All @@ -80,7 +80,7 @@
"name": "Average Database Call Duration",
"query": {
"type": "newrelic",
"select": "average(databaseDuration*1000)"
"select": "SELECT average(databaseDuration*1000) FROM Transaction"
},
"groups": [
"database"
Expand Down

0 comments on commit 913841c

Please sign in to comment.