|
| 1 | +# Grafana LGTM |
| 2 | + |
| 3 | +Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 4 | + |
| 5 | +## Introduction |
| 6 | + |
| 7 | +The Testcontainers module for Grafana LGTM. |
| 8 | + |
| 9 | +## Adding this module to your project dependencies |
| 10 | + |
| 11 | +Please run the following command to add the Grafana module to your Go dependencies: |
| 12 | + |
| 13 | +``` |
| 14 | +go get github.com/testcontainers/testcontainers-go/modules/grafanalgtm |
| 15 | +``` |
| 16 | + |
| 17 | +## Usage example |
| 18 | + |
| 19 | +<!--codeinclude--> |
| 20 | +[Creating a Grafana LGTM container](../../modules/grafana-lgtm/examples_test.go) inside_block:runGrafanaLGTMContainer |
| 21 | +<!--/codeinclude--> |
| 22 | + |
| 23 | +## Module Reference |
| 24 | + |
| 25 | +### Run function |
| 26 | + |
| 27 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 28 | + |
| 29 | +!!!info |
| 30 | + The `RunContainer(ctx, opts...)` function is deprecated and will be removed in the next major release of _Testcontainers for Go_. |
| 31 | + |
| 32 | +The Grafana LGTM module exposes one entrypoint function to create the Grafana LGTM container, and this function receives three parameters: |
| 33 | + |
| 34 | +```golang |
| 35 | +func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*GrafanaLGTMContainer, error) |
| 36 | +``` |
| 37 | + |
| 38 | +- `context.Context`, the Go context. |
| 39 | +- `string`, the Docker image to use. |
| 40 | +- `testcontainers.ContainerCustomizer`, a variadic argument for passing options. |
| 41 | + |
| 42 | +### Container Options |
| 43 | + |
| 44 | +When starting the Grafana LGTM container, you can pass options in a variadic way to configure it. |
| 45 | + |
| 46 | +#### Image |
| 47 | + |
| 48 | +If you need to set a different Grafana LGTM Docker image, you can set a valid Docker image as the second argument in the `Run` function. |
| 49 | +E.g. `Run(context.Background(), "grafana/otel-lgtm:0.6.0")`. |
| 50 | + |
| 51 | +#### Admin Credentials |
| 52 | + |
| 53 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 54 | + |
| 55 | +If you need to set different admin credentials in the Grafana LGTM container, you can set them using the `WithAdminCredentials(user, password)` option. |
| 56 | + |
| 57 | +{% include "../features/common_functional_options.md" %} |
| 58 | + |
| 59 | +### Container Methods |
| 60 | + |
| 61 | +The Grafana LGTM container exposes the following methods: |
| 62 | + |
| 63 | +!!!info |
| 64 | + All the endpoint methods return their endpoints in the format `<host>:<port>`, so please use them accordingly to configure your client. |
| 65 | + |
| 66 | +#### Grafana Endpoint |
| 67 | + |
| 68 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 69 | + |
| 70 | +The `HttpEndpoint(ctx)` method returns the HTTP endpoint to connect to Grafana, using the default `3000` port. The same method with the `Must` prefix returns just the endpoing, and panics if an error occurs. |
| 71 | + |
| 72 | +#### Loki Endpoint |
| 73 | + |
| 74 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 75 | + |
| 76 | +The `LokiEndpoint(ctx)` method returns the HTTP endpoint to connect to Loki, using the default `3100` port. The same method with the `Must` prefix returns just the endpoing, and panics if an error occurs. |
| 77 | + |
| 78 | +#### Tempo Endpoint |
| 79 | + |
| 80 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 81 | + |
| 82 | +The `TempoEndpoint(ctx)` method returns the HTTP endpoint to connect to Tempo, using the default `3200` port. The same method with the `Must` prefix returns just the endpoing, and panics if an error occurs. |
| 83 | + |
| 84 | +#### Otel HTTP Endpoint |
| 85 | + |
| 86 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 87 | + |
| 88 | +The `OtelHTTPEndpoint(ctx)` method returns the endpoint to connect to Otel using HTTP, using the default `4318` port. The same method with the `Must` prefix returns just the endpoing, and panics if an error occurs. |
| 89 | + |
| 90 | +#### Otel gRPC Endpoint |
| 91 | + |
| 92 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 93 | + |
| 94 | +The `OtelGRPCEndpoint(ctx)` method returns the endpoint to connect to Otel using gRPC, using the default `4317` port. The same method with the `Must` prefix returns just the endpoing, and panics if an error occurs. |
| 95 | + |
| 96 | +#### Prometheus Endpoint |
| 97 | + |
| 98 | +- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a> |
| 99 | + |
| 100 | +The `PrometheusHttpEndpoint(ctx)` method returns the endpoint to connect to Prometheus, using the default `9090` port. The same method with the `Must` prefix returns just the endpoing, and panics if an error occurs. |
| 101 | + |
| 102 | +## Examples |
| 103 | + |
| 104 | +### Traces, Logs and Prometheus metrics for a simple Go process |
| 105 | + |
| 106 | +In this example, a simple application is created to generate traces, logs, and Prometheus metrics. |
| 107 | +The application sends data to Grafana LGTM, and the Otel SDK is used to send the data. |
| 108 | +The example demonstrates how to set up the Otel SDK and run the Grafana LGTM module, |
| 109 | +configuring the Otel library to send data to Grafana LGTM thanks to the endpoints provided by the Grafana LGTM container. |
| 110 | + |
| 111 | +<!--codeinclude--> |
| 112 | +[App sending Otel data](../../modules/grafana-lgtm/examples_test.go) inside_block:rollDiceApp |
| 113 | +[Setup Otel SDK](../../modules/grafana-lgtm/examples_test.go) inside_block:setupOTelSDK |
| 114 | +[Run the Grafana LGTM container](../../modules/grafana-lgtm/examples_test.go) inside_block:ExampleRun_otelCollector |
| 115 | +<!--/codeinclude--> |
0 commit comments