Ambari quicklinks
自定义告警
Alert 概述
Ambari 为了帮助用户鉴别以及定位集群的问题,实现了告警(Alert)机制。在 Ambari 中预告了很多告警,这些告警被用来监测集群的各个模块以及机器的状态。对于告警来说,主要有两个概念,一个是 Alert Definition,一个是 Alert Instance
Alert Definition 就是告警的定义,其中会定义告警的检测时间间隔(interval)、类型(type)、以及阈值(threshold)等
Alert Instance 就是告警的实例:Ambari 会读取 alert definition,然后创建对应的实例(instance)去定期执行这个告警
Ambari 中 alert 的类型
Ambari 中的 alert 分为 5 种类型,分别是 WEB、Port、Metric、Aggregate 和 Script
Alert 的检查结果会以五种级别呈现,分别是 OK、WARNING,CRITICAL、UNKNOWN 和 NONE
quicklinks 快速链接
官网文档 :https://cwiki.apache.org/confluence/display/AMBARI/Quick+Links
概述
服务通过 metainfo 中加入 quicklink 的引用 ,ambari server 会解析 quicklinks.json 的数据,可以快速链接列出 Ambari Web UI
设计
一般情况 :json 文件名为 : quicklinks.json , 其位于服务的根目录下所在的 quicklinks 文件目录下。如 : HDFS/quicklinks/quicklinks.json
。也可以以不同方式命名文件,将放在自定义目录中
在 metainfo.xml 文件里面添加:
<services>
<service>
<!-- ... -->
<!-- 加载 quicklinks.json 位置,默认情况,可不写 -->
<quickLinksConfigurations-dir>quicklinks-mapred</quickLinksConfigurations-dir>
<quickLinksConfigurations>
<quickLinksConfiguration>
<fileName>quicklinks.json</fileName>
<default>true</default>
</quickLinksConfiguration>
</quickLinksConfigurations>
<!-- ... -->
</service>
<!-- ... -->
<services>
quicklinks.json 有两个主要部分 :
- configuration :确定协议( HTTP vs HTTPS)
- links:Ambari Web UI 显示的链接的元信息
{
"name": "default", --- 默认
"description": "default quick links configuration",
"configuration": {
"protocol": {
# 执行https 或http 类型
"type": "https",
"checks":[ # 检测必要性
{
"property":"HTTPS_ONLY",--- 可选 HTTP_ONLY 或 HTTPS_ONLY
"desired":"HTTPS_ONLY",
"site":"simple-site" --- 属性所在的文件
}
]
},
# 链接的配置项
"links": [
{
"name": "azkaban_web", --- 名称
"label": "Azkaban Web", --- UI 显示名
"component_name": "AZKABAN_WEB",
"requires_user_name": "false", # true:UI附加用户名在链接后
"url": "%@://%@:%@:10200",
"port": {
# 如果服务没有该端口的属性,请使用完整url属性,指定解析规则以便解析url
"http_property": "jetty.port",
"http_default_port": "8280",
"https_property": "simple.webapp.https.address",
"https_default_port": "8290",
"regex": "^(\\d+)$",
"site": "azkaban-web.properties"
}
}
]
}
}
服务添加监控
metainfo.xml
在 metainfo.xml 文件内的 <componment>
里面增加 <timelineAppid>
标签,如下述代码所示:
<timelineAppid>elasticsearch</timelineAppid>
这里需要注意字段 timelineAppId,该值是唯一的,一般用 Service Name 即可,并且不区分大小写。Metrics Collector 中的 Tmeline Server 会通过 timelineAppid 区分各个服务的 Metrics 信息
添加自定义监控信息
以 Elasticsearch 服务为例,如果要添加服务监控指标并展示的话,大概分为 3 步:
- 通过 widgets.json 文件定义服务 widgets
- 通过 metrics.json 文件声明服务指标