Skip to content

Commit 71cd719

Browse files
authored
split observability stack into two modes (#2047)
Split the observability stack into two modes
1 parent cae9a68 commit 71cd719

File tree

6 files changed

+93
-14
lines changed

6 files changed

+93
-14
lines changed

book/src/framework/observability/observability_stack.md

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

33
You can use a local observability stack, framework is connected to it by default
44

5+
Default mode includes:
6+
- Prometheus
7+
- Loki
8+
- OTEL-collector
9+
- Grafana
510
```bash
11+
# start the observability stack
612
ctf obs up
13+
# remove the stack with all the data (volumes)
14+
ctf obs d
15+
# restart the stack removing all the data (volumes)
16+
ctf obs r
717
```
818

9-
To remove it use
19+
Full stack has all the services above but also adds:
20+
- Cadvisor
21+
- Tempo
22+
- Pyroscope
23+
- PostgreSQL exporters for NodeSet databases
1024

1125
```bash
12-
ctf obs down
26+
# start the observability stack
27+
ctf obs up -f
28+
# remove the stack with all the data (volumes)
29+
ctf obs d -f
30+
# restart the stack removing all the data (volumes)
31+
ctf obs r -f
1332
```
1433

1534
Read more about how to check [logs](logs.md) and [profiles](profiling.md)

framework/.changeset/v0.10.14.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Split the observability stack into two modes: full and standard

framework/cmd/main.go

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,61 @@ func main() {
6868
Usage: "Spins up a local observability stack: Grafana, Loki, Pyroscope",
6969
Subcommands: []*cli.Command{
7070
{
71-
Name: "up",
72-
Usage: "ctf obs up",
73-
Aliases: []string{"u"},
74-
Description: "Spins up a local observability stack: Grafana, Loki, Pyroscope",
75-
Action: func(c *cli.Context) error { return framework.ObservabilityUp() },
71+
Name: "up",
72+
Usage: "ctf obs up",
73+
Aliases: []string{"u"},
74+
Flags: []cli.Flag{
75+
&cli.BoolFlag{
76+
Name: "full",
77+
Aliases: []string{"f"},
78+
Usage: "Spin up all the observability services",
79+
Value: false,
80+
},
81+
},
82+
Description: "Spins up a local observability stack. Has two modes, standard (Loki, Prometheus, Grafana and OTEL) and full including also Tempo, Cadvisor and PostgreSQL metrics",
83+
Action: func(c *cli.Context) error {
84+
if c.Bool("full") {
85+
return framework.ObservabilityUpFull()
86+
}
87+
return framework.ObservabilityUp()
88+
},
7689
},
7790
{
78-
Name: "down",
79-
Usage: "ctf obs down",
80-
Aliases: []string{"d"},
91+
Name: "down",
92+
Usage: "ctf obs down",
93+
Aliases: []string{"d"},
94+
Flags: []cli.Flag{
95+
&cli.BoolFlag{
96+
Name: "full",
97+
Aliases: []string{"f"},
98+
Usage: "Removes all the observability services (this flag exists for compatibility, all the services are always removed with 'down')",
99+
Value: false,
100+
},
101+
},
81102
Description: "Removes local observability stack",
82103
Action: func(c *cli.Context) error { return framework.ObservabilityDown() },
83104
},
84105
{
85-
Name: "restart",
86-
Usage: "ctf obs r",
87-
Aliases: []string{"r"},
106+
Name: "restart",
107+
Usage: "ctf obs r",
108+
Aliases: []string{"r"},
109+
Flags: []cli.Flag{
110+
&cli.BoolFlag{
111+
Name: "full",
112+
Aliases: []string{"f"},
113+
Usage: "Restart all observability services (this flag exists for compatibility, all the services are always removed with 'down')",
114+
Value: false,
115+
},
116+
},
88117
Description: "Restart a local observability stack",
89118
Action: func(c *cli.Context) error {
119+
// always remove all the containers and volumes to clean up the data
90120
if err := framework.ObservabilityDown(); err != nil {
91121
return err
92122
}
123+
if c.Bool("full") {
124+
return framework.ObservabilityUpFull()
125+
}
93126
return framework.ObservabilityUp()
94127
},
95128
},

framework/observability.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,30 @@ func ObservabilityUp() error {
124124
if err := NewPromtail(); err != nil {
125125
return err
126126
}
127+
err := RunCommand("bash", "-c", fmt.Sprintf(`
128+
cd %s && \
129+
docker compose up -d otel-collector prometheus loki grafana
130+
`, "compose"))
131+
if err != nil {
132+
return err
133+
}
134+
fmt.Println()
135+
L.Info().Msgf("Loki: %s", LocalLogsURL)
136+
L.Info().Msgf("Prometheus: %s", LocalPrometheusURL)
137+
L.Info().Msgf("CL Node Errors: %s", LocalCLNodeErrorsURL)
138+
L.Info().Msgf("Workflow Engine: %s", LocalWorkflowEngineURL)
139+
return nil
140+
}
141+
142+
func ObservabilityUpFull() error {
143+
L.Info().Msg("Creating full local observability stack")
144+
if err := extractAllFiles("observability"); err != nil {
145+
return err
146+
}
147+
_ = DefaultNetwork(nil)
148+
if err := NewPromtail(); err != nil {
149+
return err
150+
}
127151
err := RunCommand("bash", "-c", fmt.Sprintf(`
128152
cd %s && \
129153
docker compose up -d

framework/observability/compose/docker-compose.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ services:
8282
depends_on:
8383
- prometheus
8484
- loki
85-
- tempo
8685

8786
pyroscope:
8887
image: 'grafana/pyroscope:1.13.4'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"example": "This file is needed for local testing so embedding can work."
3+
}

0 commit comments

Comments
 (0)