Software /
code /
prosody-modules
Annotate
mod_measure_modules/mod_measure_modules.lua @ 5821:fdf3056021dc
mod_http_oauth2: Tweak fallback error text
Since the oauth error is more like the error condition, a symbolic error
code, not the most human-friendly. Many error cases do have
human-readable error descriptions that should be fine on their own, or
changed to be.
As a fallback, capitalize the error name.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 23 Dec 2023 00:01:30 +0100 |
parent | 5691:ecfd7aece33b |
rev | line source |
---|---|
5691
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 module:set_global(); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local mm = require "core.modulemanager"; |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local sm = require "core.statsmanager"; |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local measure_status = sm.metric("gauge", "prosody_module_status", "", "Prosody module status", { "host"; "module" }); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 local status_priorities = { error = 3; warn = 2; info = 1; core = 0 }; |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 function module.add_host(module) |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 local measure = measure_status:with_partial_label(module.host); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 if module.global then |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 measure = measure_status:with_partial_label(":global"); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 -- Already loaded modules |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local modules = mm.get_modules(module.host); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 for name, mod in pairs(modules) do |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 measure:with_labels(name):set(status_priorities[mod.module.status_type] or 0); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 end |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 -- TODO hook module load and unload |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 -- Future changes |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 module:hook("module-status/updated", function(event) |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 local mod = mm.get_module(event.name); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 measure:with_labels(event.name):set(status_priorities[mod and mod.module.status_type] or 0); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end); |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 end |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 |
ecfd7aece33b
mod_measure_modules: Report module statuses via OpenMetrics
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 module:add_host(); -- Initialize global context |