在datadog指标中记录销售额

时间:2019-05-21 04:06:13

标签: java statsd datadog

我正在尝试在datadog中记录我的网站销售额$金额。但是我得到的不仅仅是实际值。

我正在使用java-dogstatsd客户端和spring。我的应用程序在3台主机上运行。我记录了所有指标(使用sendWebOrder方法),但是没有运气。

@EnableConfigurationProperties({DataDogProperties.class})
@Component
public class DDMetrics {
@Autowired
DataDogProperties dataDogProperties;
@Autowired
private NonBlockingStatsDClient statsd;
private Map<TopicPartition,Long> lags = new HashMap<>();
@Bean
private NonBlockingStatsDClient initClient() {
    NonBlockingStatsDClient metricsClient = new NonBlockingStatsDClient(
            dataDogProperties.getServiceName(),
            dataDogProperties.getHostname(),
            dataDogProperties.getPort();
    return metricsClient;
}

public void sendWebOrder(WebOrder webOrder) {
    List<String> tags = new ArrayList<>();
    tags.add("transactionType:" + webOrder.getTransactionType());
    tags.add("dataSourceType:"      + webOrder.getDataSourceType()));
    statsd.count("amount_count", webOrder.getAmount(), String.join(",", tags));
    statsd.recordDistributionValue("amount_dist", webOrder.getAmount(), String.join(",", tags));
    statsd.recordHistogramValue("amount_hist", webOrder.getAmount(), String.join(",", tags));
    statsd.recordGaugeValue("amount_gauge", webOrder.getAmount(), String.join(",", tags));
    statsd.incrementCounter("weborder", String.join(",", tags));
}

我正在尝试通过transactiontype生成一个datadog列表。我在任何度量标准中均未获得正确的数量(主要尝试计数,量规和histogram.sum)。这是我的datadog配置:

{
  "viz": "toplist",
  "requests": [
    {
      "q": "top(sum:projecta.webtransactions.amount_histogram.sum{$TransactionType} by {transactiontype}, 10, 'sum', 'desc')",
      "type": "area",
      "style": {
        "palette": "dog_classic",
        "type": "solid",
        "width": "normal"
      },
      "aggregator": "sum",
      "conditional_formats": []
    }
  ],
  "autoscale": true
}

我想念什么?这是记录货币价值的正确方法吗?我必须在配置中进行任何汇总吗? 任何帮助表示赞赏。

0 个答案:

没有答案