mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* Update metrics.md Made descriptions of metrics more consistent and some smaller improvements. * Update README.md (#855) * Update README.md Smaller improvements. Fixed a typo. * Create 855.doc --------- Co-authored-by: Will Hunt <will@half-shot.uk> * Update setup.md (#857) * Update setup.md Smaller improvements such as fixes for typos, also added an example on how to pass requests from Nginx * Create 857.docs * Rename 857.docs to 857.doc --------- Co-authored-by: Will Hunt <will@half-shot.uk> * Update workers.md (#858) * Update workers.md Fixed typos Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de * Create 858.doc --------- Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de Co-authored-by: Will Hunt <will@half-shot.uk> * Update encryption.md (#860) * Update encryption.md Consistently spell Hookshot with an upper-case H as the first letter Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de * Create 860.doc --------- Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de Co-authored-by: Will Hunt <will@half-shot.uk> * Update widgets.md (#859) * Update widgets.md Consistently spell Hookshot with an upper-case H as the first letter Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de * Create 859.doc --------- Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de Co-authored-by: Will Hunt <will@half-shot.uk> * Drop Node 18, start testing Node 21 & update dependencies. (#862) * Major package upgrades * Update rust deps and fix a few things * Drop 18 testing * Use node 20 * lint rust * lint * changelog * Drop usage of SVGs, use compound elements. * Update widget API * Better support for dark mode in widgets (#863) * Major package upgrades * Update rust deps and fix a few things * Drop 18 testing * Use node 20 * lint rust * lint * changelog * Drop usage of SVGs, use compound elements. * Update widget API * Drop usage of SVGs, use compound elements. * Add dark mode for widgets * changelog * Remove yarn-error.log * Commit metrics changes * Cleanup --------- Signed-off-by: Joshua Hoffmann joshua.hoffmann@b1-systems.de Co-authored-by: Will Hunt <will@half-shot.uk>
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
/* eslint-disable no-console */
|
|
import Metrics from "../src/Metrics";
|
|
import { register } from "prom-client";
|
|
|
|
// This is just used to ensure we create a singleton.
|
|
Metrics.getMetrics();
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
const anyRegister = register as any as {_metrics: {[metricName: string]: {labelNames: string[], name: string, help: string}}};
|
|
|
|
const categories: {[title: string]: {name: string, labels: string[], help: string}[]} = {};
|
|
|
|
Object.entries(anyRegister._metrics).map(
|
|
([key, value]) => {
|
|
const [categoryName] = key.split('_');
|
|
categories[categoryName] = categories[categoryName] || [];
|
|
categories[categoryName].push({
|
|
name: key,
|
|
labels: value.labelNames,
|
|
help: value.help,
|
|
});
|
|
});
|
|
|
|
// Generate some markdown
|
|
|
|
console.log(`Prometheus Metrics
|
|
==================
|
|
|
|
You can configure metrics support by adding the following to your config:
|
|
|
|
\`\`\`yaml
|
|
metrics:
|
|
enabled: true
|
|
bindAddress: 127.0.0.1
|
|
port: 9002
|
|
\`\`\`
|
|
|
|
Hookshot will then provide metrics on \`127.0.0.1\` at port \`9002\`.
|
|
|
|
An example dashboard that can be used with [Grafana](https://grafana.com) can be found at [/contrib/hookshot-dashboard.json](https://github.com/matrix-org/matrix-hookshot/blob/main/contrib/hookshot-dashboard.json).
|
|
There are 3 variables at the top of the dashboard:
|
|
|
|

|
|
|
|
Select the Prometheus instance with your Hookshot metrics as Data Source. Set Interval to your scraping interval. Set 2x Interval to twice the Interval value ([why?](https://github.com/matrix-org/matrix-hookshot/pull/407#issuecomment-1186251618)).
|
|
|
|
Below is the generated list of Prometheus metrics for Hookshot.
|
|
|
|
`)
|
|
|
|
Object.entries(categories).forEach(([name, entries]) => {
|
|
console.log(`## ${name}`);
|
|
console.log('| Metric | Help | Labels |');
|
|
console.log('|--------|------|--------|');
|
|
entries.forEach((e) => console.log(`| ${e.name} | ${e.help} | ${e.labels.join(', ')} |`));
|
|
});
|