Containerpilot 配置文件 之 Telemetry
如果提供telemetry选项,ContainerPilot将公开可用于刮擦性能telemetry的Prometheus HTTP客户端界面。 telemetry接口被公告为consul服务。 telemetry服务的每个metric为Prometheus客户端库配置收集器。 然后,Prometheus服务器可以向telemetry终端发出HTTP请求。
配置细节如下,但这篇博客文章提供了一个用法示例和叙述 。
顶级telemetry配置定义了telemetryHTTP端点。 正如一个典型的ContainerPilot service块一样,这个端点将被通告给Consul(或其他发现服务)。 该服务将被称为containerpilot ,并将在路径/metrics 。 telemetry服务将定期向发现服务发送心跳信号,以确定其仍在运行。 telemetry服务端点没有用户定义的运行状况检查,您不需要配置poll / TTL; 它每5秒钟会发出15秒的心跳。
ContainerPilot的最小配置包括telemetry可能如下所示:
{
consul: "consul:8500",
telemetry: {
port: 9090,
interfaces: ["eth0"],
tags: ["tag1"],
metrics: [
{
namespace: "my_namespace",
subsystem: "my_subsystem",
name: "my_events_count",
help: "help text",
type: "counter"
}
]
},
jobs: [
{
name: "sensor",
exec: "/bin/sensor.sh",
timeout: "5s",
when: {
interval: "5s"
}
}
]
}
字段如下:
port是telemetry服务将向发现服务通告的端口。 (默认值为9090.)interfaces是可选的单个或数组接口规范。 如果给出,服务的IP将从匹配的第一个接口规范获得。 (默认值为["eth0:inet"])tags是可选的标签数组。 如果发现服务支持(Consul),服务将注册自己的这些标签。metrics是可选的收集器配置数组(见下文)。 如果没有提供传感器,那么telemetry端点仍将被暴露,并且将只显示关于ContainerPilot内部的telemetry。
Collector configuration
metrics字段是telemetry服务将用于配置Prometheus收集器的用户定义指标的列表。
namespace,subsystem和name是Prometheus客户端库将用于构建telemetry名称的名称。 这三个名称与下划线_连接成为Prometheus记录的最终名字。 在上面的示例中,记录的度量将被命名为my_namespace_my_subsystem_my_event_count。 你可以离开namespace和subsystem值,如果需要,将所有内容放在name字段中; 提供这些其他字段的选项只是为了方便那些以编程方式生成ContainerPilot配置的用户。 请参阅有关如何命名telemetry的最佳做法命名的Prometheus文件 。help是与Prometheus记录的指标相关联的帮助文本。 这通过给出更详细的描述对于调试非常有用。type是Prometheus将使用的收集器的类型(counter,gauge,histogram或summary)。 详见下文 。
Sensor configuration
收集器可以记录通过HTTP控制套接字发送的指标。 如果您的应用程序不能containerpilot -putmetric使用此端点,则可以使用周期性作业记录度量值并调用containerpilot-putmetric 。 一个很好的工作脚本的例子可能是:
#!/bin/bash
# check free memory
val=$(free | awk -F' +' '/Mem/{print $3}')
./containerpilot -putmetric "free_memory=$val"
Collector types
ContainerPilot支持Prometheus API中可用的四种度量标准 。 简单来说,这些是:
Counter
累积度量,表示只有一个数字值才能上升。 Counter的典型用例是某些事件数量的计数。 传感器返回的值将被添加到该度量的Counter中。
Gauge
表示可以任意上下移动的单个数值的度量。 仪表的典型用例可能是当前内存使用情况的Gauge。 传感器脚本返回的值将被设置为Gauge仪度量值的新值。
Histogram
“count”中的观察次数以及所有观察值的总和。 典型的用例可能是请求持续时间或响应大小。 当Prometheus服务器刮掉这个telemetry终端时,它会收到count和列表。 例如:
namespace_subsystem_response_bucket{le="1"} 0这表明收藏家总共看到了2个事件。 一个事件的值小于5(
namespace_subsystem_response_bucket{le="2.5"} 0
namespace_subsystem_response_bucket{le="5"} 1
namespace_subsystem_response_bucket{le="10"} 2
namespace_subsystem_response_bucket{le="+Inf"} 2le="5"),而第二个小于10。
summary
总结类似于Histogram,但是它也提供了观察总数和所有观察值的总和,它在滑动时间窗口上计算分位数。 例如:
namespace_subsystem_response_seconds_summary{quantile="0.5"} 0.3
namespace_subsystem_response_seconds_summary{quantile="0.9"} 0.5
namespace_subsystem_response_seconds_summary{quantile="0.99"} 2
这表示第50百分位数响应时间为0.3秒,第90百分位数为0.5秒,第99百分位数为2秒。
有关何时应选择Histogram与摘要的最佳做法,请参阅关于Histogram的Prometheus文档。
======================================================================================================================
{
"consul": "{{ .CONSUL }}:8500",
"logging": {
"level": "INFO",
"format": "default",
"output": "stdout"
},
"jobs": [
{
"name": '{{ .SERVICE_NAME|default "app"}}',
"exec": "/root/test/containerpilot/app.sh",
"when":{
"source":"prestart",
"once":"exitSuccess",
"timeout":"60s"
},
"restarts": "unlimited",
"port": 80,
"health": {
"exec": "/root/test/containerpilot/manage.sh health",
"interval": 5,
"ttl": 10,
"timeout": "5s"
},
"tags": [
"app",
"prod"
],
"interfaces":["enp3s0:inet"]
},
{
"name": "prestart",
"exec": "/root/test/containerpilot/manage.sh prestart",
"restarts": "never"
},
{
"name": "backup_task",
"exec": "/root/test/containerpilot/manage.sh backup",
"timeout": "1m",
"when": {
"interval": "1500ms"
}
},
{
"name": "mysql_connections",
"exec": "/root/test/containerpilot/sensor.sh measureStuff",
"timeout": "5s",
"when": {
"interval": "5s"
}
}
],
"telemetry": {
"port": 9090,
"interfaces":["enp3s0:inet"],
"metrics": [
{
"namespace": "dbaas",
"subsystem": "mysql",
"name": "connections",
"help": "mysql connections",
"type": "gauge"
},
{
"namespace": "dbaas",
"subsystem": "mysql",
"name": "disk",
"help": "mysql disk",
"type": "gauge"
}
]
}
}
======================================
#!/bin/bash
trap 'exit 2' SIGTERM
usage() {
cat <<EOF
usage: $0 [COMMAND]
Does nothing.
EOF
}
doStuff() {
echo "Running doStuff with args: $@"
}
measureStuff() {
containerpilot -putmetric "dbaas_mysql_connections=42" -putmetric "dbaas_mysql_disk=1024"
}
cmd="${1:-usage}"
shift
$cmd "$@"
Containerpilot 配置文件 之 Telemetry的更多相关文章
- Containerpilot 配置文件 之 consul
Consul ContainerPilot使用Hashicorp的consul在作为服务的容器中注册工作. Watches查询consul找出其他服务的状态. Client configuration ...
- Containerpilot 配置文件reload
containerpilot -reload -config ./containerpilot.json 进程号不变,重新加载配置文件
- Containerpilot 配置文件示例
{ consul: "localhost:8500", logging: { level: "INFO", format: "default" ...
- Containerpilot 配置文件模板
{ "consul": "{{ .CONSUL }}:8500", "logging": { "level": &quo ...
- Containerpilot 配置文件 之 Watches
watch是在consul进行监视的服务配置. watch轮询服务的状态,并在服务变得健康,变得不健康或者实例数量发生变化时发出事件. 请注意,watch不包括行为; watch只发出事件,以便job ...
- Containerpilot 配置文件 之 Jobs
ContainerPilot job是用户定义的进程和规则,用于何时执行它,如何进行健康检查,以及如何向Consul做广告. 这些规则旨在允许灵活性覆盖几乎可能要运行的任何类型的进程. 一些可能的jo ...
- 【Consul】Consul实践指导-配置文件
Agent有各种各样的配置选项,这些配置选项可以通过命令行参数的方式设定,也可用通过配置文件的方式设定--所有的配置选项都是可选的,当然也是有默认值的. 当加载配置选项时,consul是按照词典顺序从 ...
- OpenStack Ocata Telemetry 数据收集服务
1 安装配置计算服务 在所有计算节点上: 1.1 安装配置组件 安装包: # yum install -y openstack-ceilometer-compute 编辑配置文件/etc/ceilom ...
- OpenStack Ocata Telemetry 警告服务部署
下列操作在控制节点上进行: 1 准备条件 在配置OpenStack Telemetry服务之前,你必须创建数据库.服务凭证和API端点. 1.1 数据库 以root用户连接数据库服务器,创建glanc ...
随机推荐
- 分布式一致性协议之:Raft算法
一致性算法Raft详解 背景 熟悉或了解分布性系统的开发者都知道一致性算法的重要性,Paxos一致性算法从90年提出到现在已经有二十几年了,而Paxos流程太过于繁杂实现起来也比较复杂,可能也是以为过 ...
- 开发框架-开发组合:LAMP(Web应用软件组合)
ylbtech-开发框架-开发组合:LAMP(Web应用软件组合) LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写. 1.返回顶部 1. 中文名:lamp 外文名:lam ...
- 安卓手机安装虚拟定位的方法Xposed安装器+模拟位置(Xposed模块)
原文:https://www.52pojie.cn/thread-571328-1-1.html 未测试,据说只支持某些手机,小米和华为很难安装,建议买其他品牌. Xposed安装器步骤:·ROOT你 ...
- [UE4]场景光照改进PostProcessVolume
PostProcessVolume可以做的效果很多,其中就可以实现太阳光斑效果. Unbound勾上上,就表示不受“PostProcessVolume”组件的大小限制,直接应用到整个世界.如果不勾选, ...
- Unreal Engine 4 性能优化工具(Profiler Tool)
转自:http://aigo.iteye.com/blog/2296548 Profiler Tool Reference https://docs.unrealengine.com/latest/I ...
- numpy的where函数
numpy.where(condition[,x,y]) condition是条件,x,y是可选参数,这三个输入参数都是array_like的形式且三者的维度相同 当conditon的某个位置为tru ...
- JS获取url传参
function GetRequest() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new O ...
- smb.conf详解[未完]
看着玩意看的吐血!!!! baidu\google充斥着一堆错误的文章及翻译,samba.org上动辄就是this document is old and might be incurrent. 不过 ...
- Linux内存管理大图(第三稿)
http://bbs.chinaunix.net/thread-2018659-2-1.html 描述讨论在http://bbs.chinaunix.net/thread-3760371-1-1.ht ...
- BTree,B-Tree,B+Tree,B*Tree的数据结构
B树 即二叉搜索树: 1.所有非叶子结点至多拥有两个儿子(Left和Right): 2.所有结点存储一个关键字: 3.非叶子结点的左指针指向小于其关键字的子树,右指针指向大于其关键字的子树: 如: B ...