Skip to content

Commit

Permalink
Use double for values in Elasticsearch meter registry (#1421)
Browse files Browse the repository at this point in the history
Closes gh-1071
Closes gh-1420
  • Loading branch information
izeye authored and shakuzen committed May 15, 2019
1 parent f516326 commit 0caad97
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ public class ElasticMeterRegistry extends StepMeterRegistry {
static final DateTimeFormatter TIMESTAMP_FORMATTER = DateTimeFormatter.ISO_INSTANT;
private static final String ES_METRICS_TEMPLATE = "/_template/metrics_template";
private static final String INDEX_LINE = "{ \"index\" : {} }\n";
private static final String TEMPLATE_BODY = "{\"template\":\"metrics*\",\"mappings\":{\"_default_\":{\"_all\":{\"enabled\":false},\"properties\":{"
+ "\"name\":{\"type\":\"keyword\"},"
+ "\"count\":{\"type\":\"double\"},"
+ "\"value\":{\"type\":\"double\"},"
+ "\"sum\":{\"type\":\"double\"},"
+ "\"mean\":{\"type\":\"double\"},"
+ "\"duration\":{\"type\":\"double\"},"
+ "\"max\":{\"type\":\"double\"},"
+ "\"total\":{\"type\":\"double\"},"
+ "\"unknown\":{\"type\":\"double\"},"
+ "\"active\":{\"type\":\"double\"}"
+ "}}}}";

private final Logger logger = LoggerFactory.getLogger(ElasticMeterRegistry.class);

Expand Down Expand Up @@ -114,7 +126,7 @@ private void createIndexIfNeeded() {

httpClient.put(config.host() + ES_METRICS_TEMPLATE)
.withBasicAuthentication(config.userName(), config.password())
.withJsonContent("{\"template\":\"metrics*\",\"mappings\":{\"_default_\":{\"_all\":{\"enabled\":false},\"properties\":{\"name\":{\"type\":\"keyword\"}}}}}")
.withJsonContent(TEMPLATE_BODY)
.send()
.onError(response -> logger.error("failed to add metrics template to elastic: {}", response.body()));
} catch (Throwable e) {
Expand Down

0 comments on commit 0caad97

Please sign in to comment.