Pythond 采集器扩展可观测能力最佳实践

前言
本次实践主要是介绍 pythond 自定义采集器采集数据接入观测云进行非标数据的可观测。
前提条件
系统环境:Linux 主机环境
开发语言:Python 3.6.8(Python3+ 版本均可)
依赖库:requests(安装命令:python3 -m pip install requests)
接入方案
安装 DataKit
主机安装 DataKit。
复制代码
开启采集器
开启 pythond 采集器。
复制代码
复制代码
编写自定义脚本
在 /usr/local/datakit/python.d
目录下创建文件夹 mytest ,自定义脚本放在 mytest 的 py 文件中。
复制代码
自定义脚本(本示例通过 Shell 命令获取内存总量、内存使用量和自定义静态数据,其他协议也是可以的,如 SNMP、IPMI、Redfish、HTTP 等等,凡 Linux 操作系统可以执行的命令,均可以通过该方式进行观测)。
Tips:上报指标数据,对应的 value 不可以是 String 类型以下示例是上报数据转换行协议如下:pythonscript,t1=b,t2=d mem_total=mem_used,test_val=$test_val
复制代码
重启 DataKit。
复制代码
验证数据采集
Tips:如果结果不及预期,可以查看以下日志文件:
~/_datakit_pythond_cli.log
~/datakit_pythond_framework_[pythond name]_.log

效果实践
Tips:host 是观测云默认追加的 tag

在观测云控制台,通过「场景」-「新建仪表板」,可以根据上报的数据绘制 dashboard。

评论