- 网络安全
- 网络
- 后端
- 数据可视化
【免费下载链接】arkime
Arkime is an open source, large scale, full packet capturing, indexing, and database system.
Arkime Parliament 是 Arkime 项目内置的多集群监控 Web 应用(基于 Vue.js),它把分散的多个 Arkime 集群组织成分组列表,统一展示各集群的 ES 健康状态、统计指标与告警 Issue,并支持通过 Slack / Twilio / Email 发送告警。本文基于 parliament/README.md 与 parliament/parliament.js 源码,完整讲解 Parliament 的安装启动、认证角色、三大页面、Settings 参数、数据模型与底层轮询原理,帮助你在多集群生产环境中快速落地一套统一的健康监控与告警体系。
什么是 Parliament:一屏纵览多个 Arkime 集群
Parliament 是一个独立的 Node.js 服务,前端基于 Vue.js(项目由 Vue CLI 生成,见 parliament/README.md)。它的核心场景是:当你拥有多套 Arkime 集群(例如生产环境与预发布环境各一套,或者多地域多数据中心各一套)时,不需要逐个登录每个 Viewer 去检查健康状态,而是把所有这些集群聚合到同一个仪表盘中:
- 按分组(Group)展示集群列表,每个集群带跳转链接、ES 健康状态与Issue 列表;
- 支持在 Parliament 内搜索 Arkime 集群;
- 可调整数据刷新时间(界面默认 15 秒刷新一次);
- 鼠标悬停在 Issue 或 ES 健康状态上可查看详细信息。
从源码看,parliament.js 中服务端通过setInterval(() => { updateParliament(); processAlerts(); }, 10000)每 10 秒主动巡检一次所有集群(拉取健康数据与统计、清理过期 Issue 并发送告警),UI 端再按设定频率展示最新数据。
快速上手:安装与启动
从 RPM/DEB 包安装
如果使用 Arkime 的预打包版本(RPM/DEB),直接运行配置脚本:
Configure --parliament该命令会安装并启动 Parliament 的 systemd 服务(arkimeparliament,参见 release/Configure 与 release/arkimeparliament.systemd.service),默认监听8008 端口。
反向代理配置
Parliament 设计上是放在 Apache 等反向代理后面运行的,README 给出了如下 Apache 配置示例:
ProxyPassMatch ^/$ http://localhost:8008/parliament retry=0 ProxyPass /parliament/ http://localhost:8008/parliament/ retry=0启动 Parliament
node parliament.js -c /path/to/parliament.ini各启动参数说明如下:
| 参数 | 默认值 | 说明 |
|---|---|---|
-n, --name | Parliament | Parliament 的名称,适用于运行多个 Parliament 实例的场景(如生产、预发布各一个) |
-c, --config | /opt/arkime/etc/parliament.ini | 配置文件路径 |
-o <section>.<key>=<value> | — | 覆盖配置文件中的值 |
--debug | — | 提高调试级别(最多支持 2 级) |
--insecure | — | 对 https 调用禁用证书校验 |
重要提示:从 v4 升级到 v5 时,
port/key/cert等参数必须写入配置文件,不能再以命令行参数的形式传入!
关于-o覆盖参数,从 parliament.js 的实现可以看到:带.的 key 会按section.key处理,不带.的 key 会自动加上parliament.前缀,例如-o port=9000实际生效的是parliament.port=9000。
启动成功后,浏览器访问http://localhost:8008(或你在配置文件中指定的端口)即可打开 Parliament 界面。
配置文件样例
release/parliament.ini.sample 给出了最精简的配置骨架:
[parliament] # 存放 parliament 数据(分组、集群、设置)的文件路径 file=../etc/parliament.json # 监听端口 #port=8008 ### Parliament 的认证方式与 viewer/cont3xt 保持一致,请在所有组件中使用相同的配置 #usersElasticsearch=http://localhost:9200 #usersPrefix=arkime #authMode=digest #passwordSecret=password #httpRealm=Moloch其中:
file:Parliament 定义文件(parliament.json)的路径,见下文「数据模型」一节;usersElasticsearch/usersPrefix/authMode/passwordSecret/httpRealm:用于对接 Arkime 用户数据库做认证(与 Viewer 使用同一套设置);port:监听端口,默认 8008。
测试环境使用的完整配置可参考 tests/parliament.ini,其中还包含usersUrl、dbUrl、geoLite2ASN、geoLite2Country等字段,并指定file=../parliament/parliament.dev.json。
开发模式运行
若要在开发与测试环境中启动应用:
# 进入 Arkime 仓库顶层目录后执行 npm run parliament:dev该命令(定义在根目录 package.json 的parliament:dev)会以必要的配置选项启动应用(-c ../tests/parliament.ini),并将未压缩的应用文件打包到parliament/vueapp/dist目录。parliament:dev使用 Vite 打包文件,然后监视相关文件的变化,每次保存后自动重新打包。
开发模式启动后同样访问http://localhost:8008。注意 parliament/package.json 中声明了 Node 版本要求:>= 20.9.0 < 23。
认证与角色:基于 Arkime 用户数据库的访问控制
Parliament 的访问控制复用 Arkime 用户数据库。你可以在 Settings 页面的Auth(v4)区域配置,也可以在配置文件(v5)中配置(usersElasticsearch/usersPrefix/authMode/passwordSecret/httpRealm等字段)。
注意:从 v4 升级到 v5 时,在 UI 中配置的 Auth 设置会自动迁移到配置文件中。这个迁移逻辑在 parliament/upgrade.js 中有完整实现:当检测到旧版
commonAuth设置时,会将其逐项写入parliament.ini并删除旧字段。
权限分层如下:
- 所有Arkime 用户都可以查看 Parliament 仪表盘;
- 拥有
parliamentUser角色的用户,可以确认(ack)、忽略(ignore)和删除Parliament 中的 Issue; - 拥有
parliamentAdmin角色的用户,拥有parliamentUser的全部权限,并且可以添加/删除/更新分组与集群、调整顺序、管理 Parliament 设置。
在源码层面,parliament.js 通过isUser与isAdmin两个中间件做权限校验(分别调用req.user.hasRole('parliamentUser')/req.user.hasRole('parliamentAdmin')),所有会修改数据的 API 都挂载了对应的角色校验;tests/parliament.t 中也有针对「非 parliament 用户无法 acknowledge/ignore Issue、无法访问 settings 接口」的回归测试用例。
三大页面详解
Parliament 页面(主仪表盘)
主页面允许用户数据库中的任何用户查看 Parliament 中的 Arkime 集群。拥有parliamentUser或parliamentAdmin角色的用户可以与集群交互(确认/忽略 Issue)。parliamentAdmin还可以进入Edit Mode(编辑模式):切换右上角(导航栏下方)的开关即可进入,此时可以添加、更新、删除、重新排序分组(Group)与集群(Cluster)。
Issues 页面
Issues 页面列出 Parliament 当前遇到的所有 Issue。parliamentUser可以在这里:
- 忽略(ignore)Issue;
- 确认(acknowledge)Issue;
- 移除已确认的 Issue。
两条关键的自动清理规则:
- 已确认(acknowledged)的 Issue 不会显示在主 Parliament 页面,但仍保留在 Issues 页面(以灰色显示),可通过垃圾桶按钮手动移除,或等待 15 分钟自动移除(由
removeAcknowledgedAfter设置控制); - 已忽略(ignored)的 Issue 不会显示在主 Parliament 页面,但仍保留在 Issues 页面(灰色显示),可通过 ignore 下拉按钮取消忽略,或在设定的忽略时间到期后自动恢复。
从 parliament.js 的cleanUpIssues()可以看到完整的清理逻辑:未被确认的 Issue 超过removeIssuesAfter未再出现则移除;已确认的 Issue 超过removeAcknowledgedAfter未再出现则移除;若已确认的 Issue 仍然存在且超过removeAcknowledgedAfter,则会自动取消确认并重新告警。
Settings 页面
parliamentAdmin可以查看并编辑 Parliament 设置。Settings 页面包含 3 个部分:
General(通用设置)
以下设置均与 Issue 的产生和清理有关(括号内为配置文件/数据模型中的字段名,默认值以粗体标注):
- capture nodes must check in this often(
outOfDate):控制 capture 节点所在集群的时间戳可以落后于当前时间多久。若时间戳超过该设置,则向集群添加Out Of DateIssue。默认 30 秒。 - Elasticsearch query timeout(
esQueryTimeout):控制 ES 状态查询的最大持续时间。若查询超过该时间,则向集群添加ES DownIssue。默认 5 秒。 - Low Packets Threshold(
noPackets):控制 capture 节点必须收到的最小数据包数量。若节点收到的包数不足,则向集群添加Low PacketsIssue;可设置为-1完全忽略该 Issue。该设置还包含一个持续时间范围(noPacketsLength),即该问题必须持续多久才添加 Issue。默认 0 个包持续 10 秒。 - remove all issues after(
removeIssuesAfter):控制 Issue 在未再次出现时的移除时间。只要 Issue 未再次出现,到期即从集群移除。默认 60 分钟。 - remove acknowledged issues after(
removeAcknowledgedAfter):控制已确认 Issue 的移除时间。到期自动移除(无需手动使用垃圾桶按钮)。默认 15 分钟。
需要说明的是,源码 parliament.js 中的settingsDefault还包含 README 未展开的两个磁盘空间监控参数:capture 节点低磁盘阈值lowDiskSpace(默认 4,类型lowDiskSpaceType默认percentage,也可设为gb)与 ES 节点低磁盘阈值lowDiskSpaceES(默认 15)。当磁盘剩余空间低于阈值时会分别产生Low Disk Space与ES Low Disk Space黄色告警,其判断逻辑见 getStats()。此外还有hostname(用于在告警消息中附带 Parliament 仪表盘链接)与includeUrl(是否在告警中附带 Dashboard 链接)等字段。
Auth (v4)
在此配置使用 Arkime 用户数据库进行访问控制,详见上文「认证与角色」一节。
Notifiers(通知器)
可以在此为 Parliament 配置告警渠道,支持:
- Slack
- Twilio
每个通知器可以针对不同类型的 Issue 分别配置是否告警。
各通知器所需的字段定义在 common/notifier.notifme.js(基于 notifme SDK 实现):
| 通知器 | 必填字段 | 说明 |
|---|---|---|
| Slack | slackWebhookUrl | Slack Incoming Webhook 地址 |
| Twilio | accountSid、authToken、toNumber、fromNumber | Twilio 账号 ID、认证令牌、收/发短信号码 |
host、port、from、to(可选secure、user、password) | SMTP 主机、端口、发件/收件地址、用户名与密码 |
告警发送流程见 buildAlert():系统只对已开启且对应 Issue 类型已勾选的通知器发送告警,告警消息为集群标题 - Issue 消息(经过ArkimeUtil.safeStr转义以防注入),并会按 250ms 间隔串行发送以避免洪泛。还可以通过设置hostname+includeUrl在告警中附带指向该集群的 Parliament Dashboard 链接。
数据模型:Parliament 定义文件与 Issue 文件
parliament.json(Parliament 定义)
parliament.json(或你在配置中通过file=指定的任意文件)描述你的 Parliament 组成。可以手工创建,也可以使用 Parliament UI 来创建、编辑和删除分组与集群。参考示例见 parliament/parliament.example.json。
parliament.issues.json(Issue 存储)
parliament.issues.json会在运行时自动创建,用于存储与 Parliament 中各集群相关的 Issue。从 parliament.js 可以看到,如果file以.json结尾,Issue 文件名会取file去掉扩展名后加上.issues.json;文件不存在时初始化为空数组,之后每次 Issue 变更都会写回该文件。
Parliament 模型
{ // parliament object version: x, // version (number) groups: [ ... ], // list of groups in the parliament settings: { // parliament settings general: { // general settings // capture nodes need to check in at least this often (number of seconds) // if a capture node has not checked in, an Out Of Date issue will be added to the node's cluster outOfDate: 30, // Elasticsearch query timeout (number of seconds) // Aborts the queries and adds an ES Down issue if no response is received esQueryTimeout: 5, // Remove all issues after (number of minutes) // Removes issues that have not been seen again after the specified time removeIssuesAfter: 60, // Remove acknowledged issues after (number of minutes) // Removes acknowledged issues that have not been seen again after the specified time removeAcknowledgedAfter: 15 }, notifiers: { // notifiers (defined in common/notifier.js) notifierX: { // notifier (object) // name of the notifier displayed in the UI (string) name: 'slack', // turns on/off this notifier (boolean) on: false, // fields necessary to notify via this notifier (object) // (defined in common/notifier.js) fields: {}, // which issues to alert on via this notifier (object) alerts: {} } } } }Group 模型
{ // group object title: 'Group Title', // group title (string, *required) description: 'Group description', // group description (string) clusters: [ ... ] // list of clusters in the group }Cluster 模型
{ // cluster object // cluster title (string, *required) title: 'Cluster title', // cluster description (string) description: 'Cluster description', // cluster external url for links in the UI (string, *required) url: 'https://somewhere.com', // cluster local url for fetching health/stats data (string, defaults to url if not supplied) localUrl: 'https://localhost:port', // which type of cluster this is. types include: // noAlerts - no alerts, stats, health, link to cluster // multiviewer - no alerts, no stats, health, link to cluster // disabled - no alerts, no stats, no health, no link to cluster // (defaults to undefined) type: 'multiviewer', // whether to hide delta bytes per second stats (defaults to false) hideDeltaBPS: false, // whether to hide delta packet drops per second (defaults to false) hideDeltaTDPS: false, // whether to hide number of nodes (defaults to false) hideDataNodes: false, // whether to hide the total number of nodes (defaults to false) hideTotalNodes: false }补充说明(源码级):从 parliament.js 的
apiCreateCluster看,新建集群时还会初始化id(UUID)、hideMonitoring、hideArkimeNodes等字段;hideDeltaBPS、hideDeltaTDPS、hideMonitoring、hideArkimeNodes、hideDataNodes、hideTotalNodes都用于按需隐藏仪表盘上的对应统计列。type的实际行为在 updateParliament() 中体现:disabled集群完全跳过健康与统计拉取,multiviewer集群跳过统计拉取但保留健康检查,而noAlerts/multiviewer集群在 setIssue() 中不会触发告警。
Issue 模型
{ // issue object // the type of issue: esDown, esRed, esDropped, outOfDate, or noPackets (string) type: 'esDown', // the specific error encountered (string) value: 'Error: Issue Error', // human readable text to describe the type of issue (string) text: 'ES is down', // human readable title to be displayed in the UI instead of type (string) title: 'ES Down', // how severe the issue is: red or yellow (string) severity: 'red', // the ID of the cluster that the issue pertains to (string) clusterId: '1', // more verbose info to be displayed in the UI (string) // concatenation of issue title and value message: 'ES is down: Error: Issue error', // time that the issue was first noticed in ms (number) firstNoticed: 1234567890, // time that the issue was last noticed in ms (number) lastNoticed: 1234567890, // time that parliament issued an alert in ms (number) alerted: 1234567890, // time that the issue was acknowledged by a user in ms (number) acknowledged: 1234567890, // time that the issue will be ignored until in ms (number) // once the current time has passed this value, the issue will alert again ignoreUntil: 1234567890 }补充说明(源码级):parliament.js 中定义的完整 Issue 类型共 8 种——
esRed(ES 状态为红)、esDown(ES 不可达)、esDropped(ES 正在丢弃 bulk 插入,黄色)、outOfDate(节点未按时上报)、noPackets(节点收包过少)、lowDiskSpace(capture 节点磁盘不足,黄色)、lowDiskSpaceES(ES 节点磁盘不足,黄色)。另外每个 Issue 在首次被检测到时会被标记为provisional(暂定),只有当同一 Issue 在下一轮巡检中再次出现时才转为正式 Issue 并触发告警,避免误报;ignoreUntil若为-1则表示永久忽略,ms=-1的忽略请求在 ignoreIssues API 中处理。
底层原理:10 秒一轮的巡检、健康检查与统计拉取
理解 Parliament 的工作机制后,排查问题会更有方向。核心流程(updateParliament())如下:
- 每10 秒触发一次巡检(服务端
setInterval); - 遍历所有分组与集群,对非
disabled集群调用getHealth()拉取${cluster.localUrl ?? cluster.url}/eshealth.json,对非multiviewer/disabled集群调用getStats()拉取${cluster.localUrl ?? cluster.url}/api/parliament; - 根据返回数据判断并写入 Issue(ES 状态为 red →
esRed;请求超时/失败 →esDown;节点时间戳落后超过outOfDate→outOfDate;收包低于noPackets且持续超过noPacketsLength→noPackets;丢包率大于 0 →esDropped;磁盘低于阈值 →lowDiskSpace/lowDiskSpaceES); - 执行
cleanUpIssues()清理过期/已确认的 Issue,随后调用processAlerts()发送告警。
其中getStats()会在发起请求前记录当前时间,再与每个节点上报的currentTime对比计算是否超时,避免请求耗时干扰outOfDate判断。noPackets的判断使用了内存 Map 记录首次出现时间(parliament.js),只有当持续时长达到noPacketsLength才真正产生 Issue,节点恢复收包后记录会被清除。
两个值得注意的防御性设计:
- 所有从被监控集群拉取的健康/统计响应都被限制在10MB以内(
MAX_CLUSTER_RESPONSE_SIZE,见 parliament.js),防止异常 Viewer/ES 节点耗尽 Parliament 内存; - Issue 写入前会通过
validateIssues()校验,避免把空数组写坏 Issue 文件。
Parliament 数据(分组、集群、设置)默认存入 ES(<usersPrefix>parliament索引),从源码看也支持 LMDB、Redis、SQLite 等后端(Parliament.initialize() 依据dbUrl/usersUrl协议自动选择实现)。
版本升级机制
parliament/upgrade.js 负责旧版 Parliament 定义的自动升级(当前最低版本MIN_PARLIAMENT_VERSION = 7,用户库最低版本MIN_DB_VERSION = 79)。升级过程会依次处理:
- 将旧的
cluster.disabled/cluster.multiviewer布尔字段迁移为cluster.type; - 把旧版 settings 中的 notifiers 迁入数据库(与 Viewer 的通知器合并,遇到同名则重命名为
Parliament <name>,并补充roles/user/users等字段); - 将
commonAuth认证设置迁移到parliament.ini配置; - 为每个 group/cluster 生成新的 UUID 并同步更新 Issue 中的
clusterId; - 将
hideMolochNodes重命名为hideArkimeNodes,清除运行时字段(healthError、statsError、status等),最后把整个 Parliament 对象写入数据库。
启动时若检测到旧版本文件,initializeParliament() 会打印升级警告并自动执行上述迁移,成功后将升级后的文件写回磁盘。
测试与验证
Parliament 的权限与 API 行为有完整的回归测试支撑,参考 tests/parliament.t:
- 普通用户(无
parliamentUser角色)可以查看/api/parliament与/api/issues,但调用 acknowledge / ignore / removeAllAcknowledgedIssues 等写操作会收到Permission Denied: Not a Parliament user; parliamentUser可以访问 Issue 更新类接口;parliamentAdmin才能访问 notifier 类型、settings 等管理接口。
这些用例配合 tests/parliament.ini(使用authMode=regressionTests的测试认证模式)即可在本地复现权限边界。
常见问题排查要点
- Parliament 打不开:确认
node parliament.js -c ...已启动且 8008 端口未被占用;若配置了webBasePath或反向代理,注意ProxyPass的路径前缀需与浏览器访问路径一致。 - 看不到任何集群:检查
file=指向的parliament.json是否包含 groups/clusters 定义(可参考 parliament/parliament.example.json),并在 Edit Mode 下添加集群;启动时若 Parliament 定义文件无法解析,进程会报错退出(parliament.js)。 - 一直产生
ES Down:重点排查esQueryTimeout(默认 5 秒)是否过短,以及集群的url/localUrl是否可达——注意localUrl是服务端拉取健康/统计使用的地址,应指向能被 Parliament 服务器访问到的内网地址。 Low Packets误报:确认noPackets阈值(默认 0)与noPacketsLength(默认 10 秒)是否符合你的流量特征,或者直接设为-1忽略该 Issue。- 收不到告警:按 common/notifier.notifme.js 中的字段要求补齐 Slack / Twilio / Email 配置,并确保对应通知器开关与 Issue 类型勾选均已打开;可通过
/parliament/api/notifier/:id/test接口发送测试告警(见 parliament.js)。
结语
Arkime Parliament 用一套轻量的 Node.js 服务,把多集群的 ES 健康、统计指标、Issue 生命周期与第三方告警渠道串成一条完整的可观测链路。无论是几十个节点的单集群,还是跨地域的多集群矩阵,掌握本文的安装配置、角色权限、Settings 参数与数据模型,再结合 parliament/parliament.js、parliament/upgrade.js 与 tests/parliament.t 的源码与测试,你就能在生产环境中独立部署并调优自己的 Parliament 监控中心。
- 网络安全
- 网络
- 后端
- 数据可视化
【免费下载链接】arkime
Arkime is an open source, large scale, full packet capturing, indexing, and database system.
相关推荐
MicroK8s集群监控:Prometheus+Grafana部署与告警配置
MicroK8s集群监控:Prometheus+Grafana部署与告警配置 MicroK8s作为轻量级Kubernetes发行版,提供了完整的容器编排能力。集
云原生容器编排边缘计算物联网运维Apache Pulsar 集群监控部署指南:指标采集、Prometheus 配置与 Grafana 面板实践
Apache Pulsar 集群监控部署指南:指标采集、Prometheus 配置与 Grafana 面板实践 本篇技术指南围绕 Apache Pulsar 集
消息队列后端流处理TDengine 集群可视化监控实战:TDinsight 仪表盘安装、部署与告警配置全指南
TDengine 集群可视化监控实战:TDinsight 仪表盘安装、部署与告警配置全指南 TDinsight 是 TDengine 官方提供的基于 Grafa
数据库时序数据库物联网大数据实时分析云原生
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考