Skip to content

Commit 713f63a

Browse files
committed
feat(deployment): add Prometheus support for monitoring
Closes #337
1 parent ec84a60 commit 713f63a

File tree

12 files changed

+114
-15
lines changed

12 files changed

+114
-15
lines changed

packages/deployment/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Agoric testnet Deployment
2+
3+
**NOTE: This private package does not create secure public testnets by default. We recommend that public validators use their own well-understood, diversified means of deployment.**
4+
5+
You can use this package to configure privately-accessible testnets, such as on your local workstation's Docker, or a local-to-your organization LAN.
6+
7+
If you want to create a publically-accessible testnet you will at least need to:
8+
9+
1. Configure your nodes' firewalls so that only the necessary ports are accessible.
10+
2. Set up your provisioning server (node0) to expose the provisioner only on HTTPS with some form of authentication.
11+
3. **Do more, which we are not sure of**

packages/deployment/ansible/install-cosmos.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
vars:
99
- service: ag-chain-cosmos
1010
- data: "{{ SETUP_HOME }}/{{ service }}/data"
11+
- execline: "/usr/src/cosmic-swingset/lib/ag-chain-cosmos start --proxy_app=kvstore"
1112
- PERSISTENT_PEERS: "{{ lookup('file', SETUP_HOME + '/' + service + '/data/peers.txt') }}"
1213
- NUM_FILE_DESCRIPTORS: 2048
1314
roles:

packages/deployment/ansible/prepare-machine.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
gather_facts: yes
77
strategy: free
88
vars:
9-
- service: ag-chain-cosmos
109
- NODEJS_VERSION: 12
1110
roles:
1211
- prereq

packages/deployment/ansible/prereq.yml

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
3+
- hosts: all
4+
user: root
5+
gather_facts: no
6+
strategy: free
7+
vars:
8+
- service: node-exporter
9+
- user: root
10+
- to_remove:
11+
- /etc/systemd/system/node-exporter.service
12+
roles:
13+
- stop
14+
- remove
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
3+
- hosts: all
4+
user: root
5+
gather_facts: no
6+
strategy: free
7+
vars:
8+
- PROM_NODE_EXPORTER_VERSION: 0.18.1
9+
- service: node-exporter
10+
- execline: /usr/local/sbin/node_exporter
11+
- chdir: /
12+
- user: root
13+
roles:
14+
- prometheus-prereq
15+
- install
16+
- stop
17+
- start

packages/deployment/ansible/roles/install-cosmos/tasks/main.yml

+30
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,36 @@
2222
regexp: '^addr_book_strict *='
2323
line: 'addr_book_strict = false'
2424

25+
- name: "check if prometheus-tendermint.txt exists"
26+
delegate_to: localhost
27+
stat:
28+
path: "{{ SETUP_HOME }}/prometheus-tendermint.txt"
29+
register: "prommint"
30+
31+
# NOTE: This is protected by the server firewall
32+
#- name: Set prometheus_listen_addr=127.0.0.1:26660
33+
# lineinfile:
34+
# path: "/home/{{ service }}/.{{ service }}/config/config.toml"
35+
# state: present
36+
# regexp: '^prometheus_listen_addr *='
37+
# line: 'prometheus_listen_addr = "127.0.0.1:26660"'
38+
39+
- name: Set prometheus=true
40+
lineinfile:
41+
path: "/home/{{ service }}/.{{ service }}/config/config.toml"
42+
state: present
43+
regexp: '^prometheus *='
44+
line: 'prometheus = true'
45+
when: prommint.stat.exists
46+
47+
- name: Set prometheus=false
48+
lineinfile:
49+
path: "/home/{{ service }}/.{{ service }}/config/config.toml"
50+
state: present
51+
regexp: '^prometheus *='
52+
line: 'prometheus = false'
53+
when: not prommint.stat.exists
54+
2555
- name: Listen for public RPC
2656
lineinfile:
2757
path: "/home/{{ service }}/.{{ service }}/config/config.toml"

packages/deployment/ansible/roles/install/tasks/main.yml

-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44
template:
55
src: systemd.service.j2
66
dest: "/etc/systemd/system/{{service}}.service"
7-
vars:
8-
execline: "/usr/src/cosmic-swingset/lib/ag-chain-cosmos start --proxy_app=kvstore"
97
notify: reload services
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- name: Download Prometheus exporter
2+
delegate_to: localhost
3+
get_url:
4+
url: "https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-{{ PROM_NODE_EXPORTER_VERSION }}.linux-amd64.tar.gz"
5+
dest: "/root/node_exporter{{ PROM_NODE_EXPORTER_VERSION }}.tgz"
6+
7+
- name: Extract Prometheus exporter
8+
delegate_to: localhost
9+
unarchive:
10+
src: "/root/node_exporter{{ PROM_NODE_EXPORTER_VERSION }}.tgz"
11+
dest: "/root"
12+
creates: "/root/node_exporter-{{ PROM_NODE_EXPORTER_VERSION }}.linux-amd64/node_exporter"
13+
14+
- name: Install Prometheus exporter
15+
copy:
16+
src: "/root/node_exporter-{{ PROM_NODE_EXPORTER_VERSION }}.linux-amd64/node_exporter"
17+
dest: "/usr/local/sbin/node_exporter"
18+
mode: 0755
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
* to configure Prometheus endpoints on your deployed testnet nodes:
2+
1. for validator (i.e. Tendermint) on TCP port 26660 /metrics
3+
- to enable: `date | ag-chain-cosmos shell -c 'tee MYTESTNET/prometheus-tendermint.txt'`
4+
- takes effect on next `NETWORK_NAME=MYTESTNET ag-chain-cosmos bootstrap --bump`
5+
- to disable: `ag-chain-cosmos shell -c 'rm MYTESTNET/prometheus-tendermint.txt'`
6+
- takes effect on next `NETWORK_NAME=MYTESTNET ag-chain-cosmos bootstrap --bump`
7+
2. for host-level (i.e. node_exporter) on TCP port 9100 /metrics
8+
- to enable: `ag-chain-cosmos play prometheus-node-enable`
9+
- to disable: `ag-chain-cosmos play prometheus-node-disable`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
For each PR, add a file to this directory named $ISSUENUMBER.txt , and
2+
describe any downstream-visible changes in it (one per line). For libraries,
3+
this should include anything a developer using this library needs to know
4+
when they upgrade to the new version (API changes, new features, significant
5+
bugs fixed). If the PR only makes internal changes (refactorings,
6+
documentation updates), you should still add a file, but leave it empty.
7+
8+
These files will be concatenated together and added to the NEWS.md file
9+
during the release process. Their filenames will be used to indicate which
10+
issues were closed in the release.
11+
12+
See the top-level developer docs for more details.
13+

packages/deployment/main.js

+1
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ show-config display the client connection parameters
402402
needReMain([
403403
'play',
404404
'install',
405+
`-eexecline=${shellEscape('/usr/src/cosmic-swingset/lib/ag-chain-cosmos start --proxy_app=kvstore')}`,
405406
`-eserviceLines="Environment=BOOT_ADDRESS=${bootAddress}"`,
406407
]),
407408
);

0 commit comments

Comments
 (0)