Name Date Size #Lines LOC

..--

.gitignoreH A D25-Apr-202527 32

README.mdH A D25-Apr-20253 KiB11888

index.jsH A D25-Apr-20254.4 KiB145134

package-lock.jsonH A D25-Apr-202519.2 KiB479478

package.jsonH A D25-Apr-2025573 2322

README.md

1# Prom exporter for SurveyTool
2
3What is this? An exporter for <https://prometheus.io> that reads from the
4Survey Tool.
5
6## Planned Obsolescence
7
8As part of [https://unicode-org.atlassian.net/browse/CLDR-14768](CLDR-14768),
9the plan is to move the exporter itself into the SurveyTool.  This will remove the need for
10a separate exporter instance, and will change the scrape URL to something such as
11`/cldr-apps/metrics`.
12
13## Config/Installation
14
151. `npm i`
16
172. setup `config.json` as below:
18
19```json
20{
21    "instances": {
22        "cldr-smoke.unicode.org": "https://cldr-smoke.unicode.org/cldr-apps/SurveyAjax?what=status",
23        "st.unicode.org": "https://st.unicode.org/cldr-apps/SurveyAjax?what=status"
24    },
25    "port": 9099
26}
27```
28
293. `node index.js`
30
31Now, the exporter is listening on port 9099 and re-exporting ST metrics as Prometheus metrics.
32
33### As a service
34
35One possible way to keep the exporter running is to create the file:
36
37`/lib/systemd/system/prometheus-cldr-surveytool-exporter.service`
38
39with the following contents:
40
41```
42[Unit]
43Description=Prometheus exporter for CLDR SurveyTool
44Documentation=https://github.com/unicode-org/cldr/tree/main/tools/st-prom-exporter
45
46[Service]
47Restart=always
48User=prometheus
49ExecStart=/usr/bin/node /usr/local/src/cldr-st-prom-exporter/tools/st-prom-exporter/index.js $ARGS
50ExecReload=/bin/kill -HUP $MAINPID
51TimeoutStopSec=20s
52SendSIGKILL=no
53
54[Install]
55WantedBy=multi-user.target
56```
57
58Note this assumes a CLDR checkout in `/usr/local/src/cldr-st-prom-exporter` with `config.json` in that directory.
59
60Then, as root run:
61
62```shell
63# systemctl enable prometheus-cldr-surveytool-exporter.service
64# systemctl start prometheus-cldr-surveytool-exporter.service
65# systemctl status prometheus-cldr-surveytool-exporter.service
66```
67
68## Integration
69
70Here is an example prometheus.yml scrape config:
71
72```yaml
73  - job_name: 'st'
74    scrape_interval: 2m
75    scrape_timeout: 2m
76    static_configs:
77      - targets: ['localhost:9909']
78    metric_relabel_configs:
79      - source_labels: [exported_instance]
80        target_label: instance
81```
82
83Here is an alert rule to see that the surveytool is not busted:
84
85```yaml
86  - name: surveytool
87    rules:
88      - alert: surveytool_busted
89        expr: surveytool_busted == 1
90        for: 5m
91        annotations:
92          summary: "Survey Tool Busted on {{ $labels.exported_instance }}"
93          description: "Survey Tool Busted: {{ $labels.exported_instance }}, Err: {{ $labels.err}}"
94```
95
96And here is an alert rule to make sure the exporter itself is up.
97
98```yaml
99  - name: instances
100    rules:
101      - alert: ScraperDown
102        expr: up{job="st"} == 0
103        for: 5m
104        labels:
105          severity: page
106        annotations:
107          summary: "Scraper for{{ $labels.job }} down"
108          description: "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 30 minutes."
109```
110
111## License and Copyright
112
113©2020 Unicode, Inc. All Rights Reserved.
114
115For license and copyright see
116https://www.unicode.org/copyright.html
117or [../../LICENSE](../../LICENSE)
118