根据遥测数据生成符合性报告的工具。
telemeter-reporter的Python项目详细描述
遥测报告器
基于Telemeter数据生成sla符合性报告的python工具。
有关原始原型脚本,请参见notebook
目录。
安装
使用pip
安装(仅限python 3)
pip3 install telemeter-reporter
用法
配置
配置是通过一个yaml文件(在某些情况下是环境变量)提供的。命令行 工具检查配置文件的三个位置(按顺序):
TELEMETER_REPORTER_CONFIG
环境变量--config
或-c
标志的参数~/.telemeter_reporter.yml
提供了一个示例配置文件(reporter_confg.yml.tmpl
)。下面是每个键的说明。所有钥匙都是必需的
除非另有说明。
css
:在这里提供一个级联样式表,以便插入到html格式的报告中(可选)html
:在这里提供html来覆盖内置模板。任何${title}
、${style}
、${table}
,或${footer}
将被(分别)报表标题、原始css(内置样式表或css
从上面),显示结果的html表,或显示何时生成报告以及报告的长度的页脚。 需要(可选)api.telemeter.url
:提供普罗米修斯兼容api的任何服务的urlapi.telemeter.token
:遥测api(即oauth)的登录令牌(如果设置了TELEMETER_TOKEN
env var,则可以省略)api.uhc.url
:uhc http api的urlapi.uhc.public_key
:用于验证所提供jwt的真实性的公钥(可以省略以禁用令牌 验证,但不建议这样做。红帽的公钥在示例配置文件中提供)api.uhc.token
:“脱机访问”uhc api的jwt令牌(如果设置了UHC_TOKEN
env var,则可以省略)clusters
:在这里提供uhc查询的字符串列表。每个查询返回的集群id都是 在上报告(可以用--uhc-query
标志覆盖)global_vars
:在这里提供字符串/int/float的列表,使它们作为每个规则的全局变量可用。为了 例如,在这里提供- foo: "bar"
将用bar
替换每个规则查询中${foo}
的任何实例。至少, 您应该在这里提供一个duration
变量(以天为单位)(可以用--override
标志覆盖)rules
:提供要计算的sli规则列表(见下文)。您也可以在这里定义局部变量,例如rules[i].foo
, 它将被插入到该规则的查询中,代替像${foo}
这样的选择器(类似于global_vars
)rules[i].name
:规则的可读名称rules[i].description
:规则的可读描述(可选,仅在html工具提示中显示)rules[i].goal
:查询结果的目标值。通常以0到1.0之间的浮动表示的百分比rules[i].query
:返回sli当前值(将与目标进行比较)的有效promql查询。 任何${sel}
的实例都将替换为_id=<cluster_id>
。您也可以使用全局变量(请参见global_vars
以上)
命令行工具
$ telemeter-reporter -h
usage: telemeter-reporter [-h] [-c PATH] [-f FMT] [-u QUERY] [-t TITLE]
[-i TIME] [-b] [-a] [-n] [-m] [-p] [-l LEVEL]
[-o VARS]
output
Tool for generating reports on SLA/SLO compliance using Telemeter-LTS data
positional arguments:
output Destination path for the generated report (- = stdout)
optional arguments:
-h, --help show this help message and exit
-c PATH, --config PATH
Path to YAML file containing configuration data.
Default: ~/.telemeter_reporter.yml
-f FMT, --format FMT Format for the report. Can be provided multiple times
(see --auto-ext). Options: ['simple', 'plain', 'html',
'csv', 'grid', 'fancy_grid', 'github', 'jira',
'latex']. Default: simple
-u QUERY, --uhc-query QUERY
Report on all clusters returned by this query to the
UHC API
-t TITLE, --title TITLE
Optional title for HTML reports
-i TIME, --time TIME Generate a report at a certain point in the past.
Strings like '2 weeks ago', 'last Monday', 'yesterday
at 8pm', or 'October 1, 2018' are all acceptable
-b, --no-browser Don't open the resulting report in a web browser (if
HTML report is selected)
-a, --auto-ext Automatically append a file extension onto the
provided output path. Enabled by default when --format
is used multiple times. Has no effect when output =
stdout.
-n, --no-duration-adjust
Disable automatic duration adjustment. By default, any
user-defined 'duration' global query var is overridden
with the cluster age if duration > cluster age.
Clusters triggering this adjustment will have an
asterisk appended to their name. This flag will
disable this behavior.
-m, --minify Minify HTML output
-p, --parents Same behavior as mkdir's --parents option. Creates
parent directories in the output path if necessary.
-l LEVEL, --log LEVEL
Set the verbosity/logging level. Options: ['critical',
'error', 'warning', 'info', 'debug']
-o VARS, --override VARS
Override global variables set in the configuration
file. Provide a valid Python dict string, e.g.
"{'duration': 28}"
注意:参数-u
覆盖配置文件中提供的任何clusters
列表。
示例
28天简单报告
$ telemeter-reporter -f simple -o "{'duration':28}"
Cluster CtrlPlane CtrlPlane CtrlPlane CtrlPlane CtrlPlane CtrlPlane
General General API API etcd etcd
Goal Perf. Goal Perf. Goal Perf.
-------------- ----------- ----------- ----------- ----------- ----------- -----------
test-cluster-1 99.500% 100.00% 99.900% 99.999% 99.900% 95.982%
test-cluster-2 99.500% 100.00% 99.900% 99.999% 99.900% 95.992%
输出到Github风格的降价文件
$ telemeter-reporter -f github output.md
$ telemeter-reporter -f simple -o "{'duration':28}"
Cluster CtrlPlane CtrlPlane CtrlPlane CtrlPlane CtrlPlane CtrlPlane
General General API API etcd etcd
Goal Perf. Goal Perf. Goal Perf.
-------------- ----------- ----------- ----------- ----------- ----------- -----------
test-cluster-1 99.500% 100.00% 99.900% 99.999% 99.900% 95.982%
test-cluster-2 99.500% 100.00% 99.900% 99.999% 99.900% 95.992%
$ telemeter-reporter -f github output.md
output.md
内容:
Cluster | CtrlPlane General Goal | CtrlPlane General Perf. | CtrlPlane API Goal | CtrlPlane API Perf. | CtrlPlane etcd Goal | CtrlPlane etcd Perf. | CtrlPlane Latency Goal | CtrlPlane Latency Perf. | Registry General Goal | Registry General Perf. | Compute General Goal | Compute General Perf. | Compute Resiliency Goal | Compute Resiliency Perf. | Support Monitoring Goal | Support Monitoring Perf. |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
osd-v4stg-aws | 99.500% | 100.00% | 99.900% | 99.999% | 99.900% | 95.982% | 99.500% | 100.00% | 99.000% | 95.982% | 99.500% | 100.00% | 99.000% | 100.00% | 99.990% | 100.00% |
osd-v4prod-aws | 99.500% | 100.00% | 99.900% | 99.999% | 99.900% | 95.992% | 99.500% | 100.00% | 99.000% | 95.942% | 99.500% | 98.800% | 99.000% | 98.353% | 99.990% | 100.00% |