https://github.com/codepumper/go-grafana-stack-helpers
Grafana Stack Go Utils is a collection of reusable components and utilities in Go for working with the Grafana stack.
https://github.com/codepumper/go-grafana-stack-helpers
go grafana grafana-client loki opentelemetry promtail tempo
Last synced: 2 months ago
JSON representation
Grafana Stack Go Utils is a collection of reusable components and utilities in Go for working with the Grafana stack.
- Host: GitHub
- URL: https://github.com/codepumper/go-grafana-stack-helpers
- Owner: codepumper
- License: apache-2.0
- Created: 2023-07-15T11:48:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-26T12:03:21.000Z (over 1 year ago)
- Last Synced: 2025-01-19T17:27:28.582Z (4 months ago)
- Topics: go, grafana, grafana-client, loki, opentelemetry, promtail, tempo
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Grafana Stack Go Utils
Grafana Stack Go Utils is a collection of reusable components and utilities in Go for working with the Grafana stack. This repository provides high-level implementations and examples that demonstrate how to easily utilize the Grafana, Loki, Promtail, and other components within a Go application.
## Features
- Docker-compose and configuration files for setting up the Grafana stack
- Tracing client for distributed tracing using Grafana Tempo or other tracing backends
- Metrics client for collecting and reporting application-specific metrics to Prometheus or other metrics systems
- Logging package for easy integration with Prometheus, Opentelemetry and Grafana Loki## Tracing
## Metrics
## Logging
At this time, OpenTelemetry for Go does not provide a built-in logging implementation. To address this, we can utilize Promtail, which is part of the Grafana Loki project, for log forwarding to OpenTelemetry.
The logging package uses Promtail for log management. **Promtail** collects logs and pushes them to the **OpenTelemetry collector**, which further processes and forwards the logs to the **Loki exporter**. The exporter translates and transmits the logs to **Loki for storage and analysis**. This setup enables centralized log management and integration with other observability data through the OpenTelemetry ecosystem.
### Usage
To use the Logging Package in your Go project, simply import it:
```go
import "github.com/codepumper/go-grafana-stack-helpers/logging"
```Here is a quick example that demonstrates how to use the Logging Package:
```go
package mainimport (
"github.com/codepumper/go-grafana-stack-helpers/logging"
)func main() {
appName := "my-app"
labels := "{application=\"" + appName + "\"}"err := logging.InitLogger("json", labels, nil)
if err != nil {
fmt.Println("Failed to initialize Logger")
}logging.Infof("This is an info message")
logging.Shutdown()
}```
---
License
The Packages in this repository are open source and available under the Apache License 2.0. See the LICENSE file for more information.