alerta统一命令行工具和sdk

alerta的Python项目详细描述


Alerta命令行工具

Build StatusGitter chatCoverage Status

Alerta监控系统的统一命令行工具、终端GUI和python SDK

screen shot

相关项目可以在Alerta Org Repo上找到,地址是https://github.com/alerta/


python 2.7支持为eol

从6.0版开始,仅支持Python3.5+。版本5.2是 最后一个支持Python2.7和此版本的功能增强在 2018年8月31日。只有关键的错误修复才会被移植到5.2版。

安装

要安装alerta cli工具,请运行::

$ pip install alerta

配置

选项可以在配置文件中设置为环境变量或在命令行上设置。 配置文件可用于在不同的配置设置之间轻松切换。

OptionConfig FileEnvironment VariableOptional ArgumentDefault
filen/a^{}n/a^{}
profileprofile^{}^{}None
endpointendpoint^{}^{}^{}
keykey^{}n/aNone
timezonetimezonen/an/aEurope/London
SSL verifysslverify^{}n/averify SSL certificates
timeouttimeoutn/an/a5s TCP connection timeout
outputoutputn/a^{}simple
colorcolor^{}^{}, ^{}color on
debugdebug^{}^{}no debug

示例

配置文件~/.alerta.conf

[DEFAULT]
timezone = Australia/Sydney
# output = psql
profile = production

[profile production]
endpoint = https://api.alerta.io
key = demo-key

[profile development]
endpoint = https://localhost:8443
sslverify = off
timeout = 10.0
debug = yes

环境变量

默认情况下,将环境变量设置为使用生产配置设置:

$ export ALERTA_CONF_FILE=~/.alerta.conf
$ export ALERTA_DEFAULT_PROFILE=production

$ alerta query

以及在需要时切换到开发配置设置,请使用--profile选项:

$ alerta --profile development query

用法

$ alerta
Usage: alerta [OPTIONS] COMMAND [ARGS]...

  Alerta client unified command-line tool.

Options:
  --config-file <FILE>      Configuration file.
  --profile <PROFILE>       Configuration profile.
  --endpoint-url <URL>      API endpoint URL.
  --output-format <FORMAT>  Output format. eg. simple, grid, psql, presto, rst
  --color / --no-color      Color-coded output based on severity.
  --debug                   Debug mode.
  --help                    Show this message and exit.

Commands:
  ack         Acknowledge alerts
  blackout    Suppress alerts
  blackouts   List alert suppressions
  close       Close alerts
  customer    Add customer lookup
  customers   List customer lookups
  delete      Delete alerts
  heartbeat   Send a heartbeat
  heartbeats  List heartbeats
  help        Show this help
  history     Show alert history
  key         Create API key
  keys        List API keys
  login       Login with user credentials
  logout      Clear login credentials
  perm        Add role-permission lookup
  perms       List role-permission lookups
  query       Search for alerts
  raw         Show alert raw data
  revoke      Revoke API key
  send        Send an alert
  status      Display status and metrics
  tag         Tag alerts
  token       Display current auth token
  unack       Un-acknowledge alerts
  untag       Untag alerts
  update      Update alert attributes
  uptime      Display server uptime
  user        Update user
  users       List users
  version     Display version info
  whoami      Display current logged in user

python sdk

alerta client python包也可以用作python SDK

示例

>>> from alertaclient.api import Client

>>> client = Client(key='NGLxwf3f4-8LlYN4qLjVEagUPsysn0kb9fAkAs1l')
>>> client.send_alert(environment='Production', service=['Web', 'Application'], resource='web01', event='HttpServerError', value='501', text='Web server unavailable.')
Alert(id='42254ef8-7258-4300-aaec-a9ad7d3a84ff', environment='Production', resource='web01', event='HttpServerError', severity='normal', status='closed', customer=None)

>>> [a.id for a in client.search([('resource','~we.*01'), ('environment!', 'Development')])]
['42254ef8-7258-4300-aaec-a9ad7d3a84ff']

>>> client.heartbeat().serialize()['status']
'ok'

许可证

Alerta monitoring system and console
Copyright 2012-2019 Nick Satterly

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java从arraylist元素调用方法   开关案例中的java错误。。。代码不返回任何内容   在TeamCity:Task:app:processDebugResources上使用Gradle进行构建时java失败   Android Studio的java Gradle同步(SDK)问题   小程序中的java Tic Tack Toe游戏:图像不工作   火柴ABC12;10;250.3使用regexjava   java如何在任务栏的系统托盘中隐藏JFrame   java ListProperty<T>与ObjectProperty<ObservableList<T>>   java如何将resultset数据转换为我的对象。以下是数据的格式   JavaJSF2和oracle   java Junit和EasyMock意外失败   使用java从生成的xml文档中删除xml声明   使用high ResultSet时某些表的java ArrayIndexOutOfBoundsException。fetchSize()   java检测点击按钮   while循环不会结束(Java)   java如何通过JUNIT将数据与文件进行比较?   hadoop Hive Java API寄存器JAR