@@ -24,18 +24,24 @@ repositories.
24
24
The functionality in this package is grouped by logical purpose into
25
25
the following non-test files:
26
26
27
- | Filename | Types | Purpose |
28
- | :------------------| :------------| :-----------------------------------------------|
29
- | defaults.go | | Defines common default configuration |
30
- | flags.go | FlagsMap | Simplifies configuration of avalanchego flags |
31
- | genesis.go | | Creates test genesis |
32
- | network.go | Network | Orchestrates and configures temporary networks |
33
- | network_config.go | Network | Reads and writes network configuration |
34
- | node.go | Node | Orchestrates and configures nodes |
35
- | node_config.go | Node | Reads and writes node configuration |
36
- | node_process.go | NodeProcess | Orchestrates node processes |
37
- | subnet.go | Subnet | Orchestrates subnets |
38
- | utils.go | | Defines shared utility functions |
27
+ | Filename | Types | Purpose |
28
+ | :----------------------------| :------------| :----------------------------------------------------|
29
+ | collectors.go | | Starts and stops collectors for logs and metrics |
30
+ | defaults.go | | Defines common default configuration |
31
+ | detached_process_default.go | | Configures detached processes for darwin and linux |
32
+ | detached_process_windows.go | | No-op detached process configuration for windows |
33
+ | flags.go | FlagsMap | Simplifies configuration of avalanchego flags |
34
+ | genesis.go | | Creates test genesis |
35
+ | kube.go | | Library for Kubernetes interaction |
36
+ | local_network.go | | Defines configuration for the default local network |
37
+ | network.go | Network | Orchestrates and configures temporary networks |
38
+ | network_config.go | Network | Reads and writes network configuration |
39
+ | network_test.go | | Simple test round-tripping Network serialization |
40
+ | node.go | Node | Orchestrates and configures nodes |
41
+ | node_config.go | Node | Reads and writes node configuration |
42
+ | node_process.go | NodeProcess | Orchestrates node processes |
43
+ | subnet.go | Subnet | Orchestrates subnets |
44
+ | utils.go | | Defines shared utility functions |
39
45
40
46
## Usage
41
47
@@ -280,35 +286,54 @@ shared.
280
286
### Example usage
281
287
282
288
``` bash
283
- # Start prometheus to collect metrics
284
- PROMETHEUS_USERNAME= < username > PROMETHEUS_PASSWORD= < password > ./scripts/run_prometheus.sh
289
+ # Start a nix shell to ensure the availability of promtail and prometheus.
290
+ nix develop
285
291
286
- # Start promtail to collect logs
287
- LOKI_USERNAME=< username> LOKI_PASSWORD=< password> ./scripts/run_promtail.sh
292
+ # Enable collection of logs and metrics
293
+ PROMETHEUS_USERNAME=< username> \
294
+ PROMETHEUS_PASSWORD=< password> \
295
+ LOKI_USERNAME=< username> \
296
+ LOKI_PASSWORD=< password> \
297
+ ./bin/tmpnetctl start-collectors
288
298
289
299
# Network start emits link to grafana displaying collected logs and metrics
290
300
./bin/tmpnetctl start-network
291
301
292
- # Configure metrics collection from a local node binding to the default API
293
- # port of 9650 and storing its logs in ~/.avalanchego/logs. The script will
294
- # also emit a link to grafana.
295
- ./scripts/configure-local-metrics-collection.sh
302
+ # When done with the network, stop the collectors
303
+ ./bin/tmpnetctl stop-collectors
296
304
```
297
305
306
+ ### Starting collectors
307
+
308
+ Collectors for logs and metrics can be started by `tmpnetctl
309
+ start-collectors`:
310
+
311
+ - Requires that the following env vars be set
312
+ - ` PROMETHEUS_USERNAME `
313
+ - ` PROMETHEUS_PASSWORD `
314
+ - ` LOKI_USERNAME `
315
+ - ` LOKI_PASSWORD `
316
+ - Requires that binaries for promtail and prometheus be available in the path
317
+ - Starting a development shell with ` nix develop ` is one way to
318
+ ensure this and requires the [ installation of
319
+ nix] ( https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#install-nix ) .
320
+ - Starts prometheus in agent mode configured to scrape metrics from
321
+ configured nodes and forward them to
322
+ https://prometheus-poc.avax-dev.network .
323
+ - Starts promtail configured to collect logs from configured nodes
324
+ and forward them to https://loki-poc.avax-dev.network .
325
+
326
+ ### Stopping collectors
327
+
328
+ Collectors for logs and metrics can be stopped by `tmpnetctl
329
+ stop-collectors`:
330
+
298
331
### Metrics collection
299
332
300
333
When a node is started, configuration enabling collection of metrics
301
334
from the node is written to
302
335
` ~/.tmpnet/prometheus/file_sd_configs/[network uuid]-[node id].json ` .
303
336
304
- The ` scripts/run_prometheus.sh ` script starts prometheus in agent mode
305
- configured to scrape metrics from configured nodes and forward the
306
- metrics to a persistent prometheus instance. The script requires that
307
- the ` PROMETHEUS_USERNAME ` and ` PROMETHEUS_PASSWORD ` env vars be set. By
308
- default the prometheus instance at
309
- https://prometheus-poc.avax-dev.network will be targeted and
310
- this can be overridden via the ` PROMETHEUS_URL ` env var.
311
-
312
337
### Log collection
313
338
314
339
Nodes log are stored at `~ /.tmpnet/networks/[ network id] /[ node
@@ -320,13 +345,6 @@ collection of logs for the node is written to
320
345
`~ /.tmpnet/promtail/file_sd_configs/[ network
321
346
uuid] -[ node id] .json`.
322
347
323
- The ` scripts/run_promtail.sh ` script starts promtail configured to
324
- collect logs from configured nodes and forward the results to loki. The
325
- script requires that the ` LOKI_USERNAME ` and ` LOKI_PASSWORD ` env vars be
326
- set. By default the loki instance at
327
- https://loki-poc.avax-dev.network will be targeted and this
328
- can be overridden via the ` LOKI_URL ` env var.
329
-
330
348
### Labels
331
349
332
350
The logs and metrics collected for temporary networks will have the
0 commit comments