Skip to content

Commit f97799c

Browse files
committed
pg debug dashboard
1 parent ddb6854 commit f97799c

File tree

14 files changed

+3353
-16
lines changed

14 files changed

+3353
-16
lines changed

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
- [Metrics](framework/observability/metrics.md)
3232
- [Logs](framework/observability/logs.md)
3333
- [Profiling](framework/observability/profiling.md)
34+
- [PostgreSQL](framework/observability/postgresql.md)
3435
- [Traces]()
3536
- [Blockscout](framework/observability/blockscout.md)
3637
- [Components](framework/components/overview.md)

book/src/framework/observability/blockscout.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,39 @@
22

33
You can use local [Blockscout](https://www.blockscout.com/) instance to debug EVM smart contracts.
44

5+
Some images require `ghcr` auth, login first and pass the token:
6+
7+
```
8+
gh auth token | docker login ghcr.io -u github-username --password-stdin
9+
```
10+
11+
Start Blockscout
12+
513
```
614
ctf bs up
715
```
16+
817
Your `Blockscout` instance is up on [localhost](http://localhost)
918

1019
To remove it, we also clean up all Blockscout databases to prevent stale data when restarting your tests.
20+
1121
```
1222
ctf bs down
1323
```
1424

1525
## Selecting Blockchain Node
1626

1727
By default, we connect to the first `anvil` node, but you can select the node explicitly
28+
1829
```
1930
ctf bs -r http://host.docker.internal:8545 d
2031
ctf bs -r http://host.docker.internal:8555 d
2132
```
2233

2334
<div class="warning">
2435

25-
Blockscout isn’t ideal for local, ephemeral environments, as it won’t re-index blocks and transactions on test reruns. The easiest approach is to set up Blockscout first, initialize the test environment, switch to the [cache](../components/caching.md) config, and run tests without restarting RPC nodes.
36+
Blockscout isn’t ideal for local, ephemeral environments, as it won’t re-index blocks and transactions on test reruns. The easiest approach is to set up Blockscout first, initialize the test environment, switch to the [cache](../components/caching.md) config, and run tests without restarting RPC nodes.
2637

2738
Otherwise, use `ctf bs r` each time you restart your test with a fresh docker environment.
28-
</div>
39+
40+
</div>
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# Local Observability Stack
22

33
You can use a local observability stack, framework is connected to it by default
4+
45
```bash
56
ctf obs up
67
```
8+
79
To remove it use
10+
811
```bash
912
ctf obs down
1013
```
1114

12-
Read more about how to check [logs](logs.md) and [profiles](profiling.md)
15+
Read more about how to check [logs](logs.md) and [profiles](profiling.md)
16+
17+
## Helpful links for your local setup
18+
19+
- [Loki](http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22P8E80F9AEF21F6940%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22P8E80F9AEF21F6940%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1)
20+
- [Prometheus](http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22PBFA97CFB590B2093%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22range%22:true,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22PBFA97CFB590B2093%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1)
21+
- [PostgreSQL](http://localhost:3000/d/000000039/postgresql-database?orgId=1&refresh=10s&var-DS_PROMETHEUS=PBFA97CFB590B2093&var-interval=$__auto_interval_interval&var-namespace=&var-release=&var-instance=postgres_exporter_0:9187&var-datname=All&var-mode=All&from=now-5m&to=now)
22+
- [Pyroscope](http://localhost:4040)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# PostgreSQL
2+
3+
## Metrics
4+
5+
You can go to [this](http://localhost:3000/d/000000039/postgresql-database?orgId=1&refresh=10s&var-DS_PROMETHEUS=PBFA97CFB590B2093&var-interval=$__auto_interval_interval&var-namespace=&var-release=&var-instance=postgres_exporter_0:9187&var-datname=All&var-mode=All&from=now-5m&to=now) dashboard and select `Instance`.
6+
7+
We run exporter for the first 5 nodes, that should be enough to debug performance issues.
8+
9+
## Data sources and raw queries
10+
11+
You can use `PostgreSQL X` datasources, first 5 nodes to select things for your [dashboards](http://localhost:3000/explore?panes=%7B%22qrr%22:%7B%22datasource%22:%22P4DD770FAD7295D26%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22datasource%22:%7B%22type%22:%22postgres%22,%22uid%22:%22P4DD770FAD7295D26%22%7D,%22format%22:%22table%22,%22rawSql%22:%22select%20%2A%20from%20sessions;%22,%22editorMode%22:%22code%22,%22sql%22:%7B%22columns%22:%5B%7B%22type%22:%22function%22,%22parameters%22:%5B%5D%7D%5D,%22groupBy%22:%5B%7B%22type%22:%22groupBy%22,%22property%22:%7B%22type%22:%22string%22%7D%7D%5D,%22limit%22:50%7D,%22rawQuery%22:true%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1) or debug.

book/src/framework/verify.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Verifying Contracts
22

3+
You need to install [Foundry](https://book.getfoundry.sh/getting-started/installation) first, `forge` should be available in your `$PATH`.
4+
35
Check out our [example](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/examples/myproject/verify_test.go) of programmatically verifying contracts using `Blockscout` and `Foundry`. You'll need to provide:
46

57
- The path to your Foundry directory
@@ -11,6 +13,7 @@ Check out our [example](https://github.com/smartcontractkit/chainlink-testing-fr
1113
"example_components/onchain",
1214
"src/Counter.sol",
1315
"Counter",
16+
"0.8.20" // check your file compiler version on the first line
1417
)
1518
require.NoError(t, err)
16-
```
19+
```

framework/.changeset/v0.4.6.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Add PostgreSQL exporters and dashboard
2+
- Update Blockscout docs, add ghcr auth example

framework/cmd/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import (
1717
var embeddedObservabilityFiles embed.FS
1818

1919
const (
20-
LocalLogsURL = "http://localhost:3000/explore"
21-
LocalPyroScopeURL = "http://localhost:4040"
20+
LocalLogsURL = "http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22P8E80F9AEF21F6940%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22P8E80F9AEF21F6940%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
21+
LocalPrometheusURL = "http://localhost:3000/explore?panes=%7B%22qZw%22:%7B%22datasource%22:%22PBFA97CFB590B2093%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22range%22:true,%22datasource%22:%7B%22type%22:%22prometheus%22,%22uid%22:%22PBFA97CFB590B2093%22%7D%7D%5D,%22range%22:%7B%22from%22:%22now-6h%22,%22to%22:%22now%22%7D%7D%7D&schemaVersion=1&orgId=1"
22+
LocalPostgresDebugURL = "http://localhost:3000/d/000000039/postgresql-database?orgId=1&refresh=10s&var-DS_PROMETHEUS=PBFA97CFB590B2093&var-interval=$__auto_interval_interval&var-namespace=&var-release=&var-instance=postgres_exporter_0:9187&var-datname=All&var-mode=All&from=now-5m&to=now"
23+
LocalPyroScopeURL = "http://localhost:4040"
2224
)
2325

2426
func main() {

framework/cmd/observability.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func observabilityUp() error {
2222
}
2323
fmt.Println()
2424
framework.L.Info().Msgf("Loki: %s", LocalLogsURL)
25+
framework.L.Info().Msgf("Prometheus: %s", LocalPrometheusURL)
26+
framework.L.Info().Msgf("PostgreSQL: %s", LocalPostgresDebugURL)
2527
framework.L.Info().Msgf("Pyroscope: %s", LocalPyroScopeURL)
2628
return nil
2729
}

framework/cmd/observability/compose/conf/prometheus.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,29 @@ scrape_configs:
55
- job_name: 'ctf'
66
metrics_path: /metrics
77
docker_sd_configs:
8-
- host: "unix:///var/run/docker.sock"
8+
- host: 'unix:///var/run/docker.sock'
99
refresh_interval: 20s
1010
relabel_configs:
11-
- source_labels: [ __meta_docker_port_private ]
11+
- source_labels: [__meta_docker_port_private]
1212
regex: '6688'
1313
action: keep
1414
- job_name: cadvisor
1515
scrape_interval: 10s
1616
static_configs:
1717
- targets:
1818
- cadvisor:8080
19+
- job_name: 'postgres_exporter_0'
20+
static_configs:
21+
- targets: ['postgres_exporter_0:9187']
22+
- job_name: 'postgres_exporter_1'
23+
static_configs:
24+
- targets: ['postgres_exporter_1:9187']
25+
- job_name: 'postgres_exporter_2'
26+
static_configs:
27+
- targets: ['postgres_exporter_2:9187']
28+
- job_name: 'postgres_exporter_3'
29+
static_configs:
30+
- targets: ['postgres_exporter_3:9187']
31+
- job_name: 'postgres_exporter_4'
32+
static_configs:
33+
- targets: ['postgres_exporter_4:9187']

0 commit comments

Comments
 (0)