-1

我有一个带有 10 个端点(合同)的 API。我正在将日志发送到 IIS 以从 API 发送到数据狗。我还在服务器上安装了数据狗代理。

现在我正在尝试为每秒所有端点命中创建图表。只有一个图表,所有端点 TPS 都将显示在图表上。我怎样才能做到这一点?有什么建议么?

我试图创建不同的矩阵但无法实现这一点。

我读过需要创建解析器文件。

import time
from datetime import datetime
 ...
def my_log_parser(logger, test):
metric_name, date, metric_value, extras = line.split('|')
# Convert the iso8601 date into a unix timestamp, assuming the timestamp
# string is in the same timezone as the machine that's parsing it.
date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
tags = extras.split(',')
date = time.mktime(date.timetuple())
metric_attributes = {
    'tags': tags,
    'metric_type': 'gauge',
}
return (metric_name, date, metric_value, metric_attributes)
4

1 回答 1

0

实际上,您需要做的是创建一个通用方法。

Create counter is the metric provided by the dataDog. 
val metric:mutable.Map[String, Counter]
def updateCounter(metricName:String, increment:Int, tags:Map[String, String])={
If(metric.isDefinedAt(metricName)){
//update the existing counter in metric map
}else{
//create the counter and update the metric map
}
}

现在,当您到达不同的不同端点时,只需调用 updateCounter 方法将使用您的路线的特定名称捕获您的指标。

例如,您有类似加减法的路由,然后使用度量名称加减法调用更新计数器方法。

于 2018-05-21T14:41:57.530 回答