Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cristalhq/sqlmetrics
Prometheus metrics for Go database/sql via VictoriaMetrics/metrics
https://github.com/cristalhq/sqlmetrics
db go golang metrics monitoring observability prometheus sql victoriametrics
Last synced: 9 days ago
JSON representation
Prometheus metrics for Go database/sql via VictoriaMetrics/metrics
- Host: GitHub
- URL: https://github.com/cristalhq/sqlmetrics
- Owner: cristalhq
- License: mit
- Created: 2021-06-10T16:48:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-03T09:12:47.000Z (over 1 year ago)
- Last Synced: 2024-06-19T01:58:00.206Z (5 months ago)
- Topics: db, go, golang, metrics, monitoring, observability, prometheus, sql, victoriametrics
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 23
- Watchers: 3
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sqlmetrics
[![build-img]][build-url]
[![pkg-img]][pkg-url]
[![reportcard-img]][reportcard-url]
[![coverage-img]][coverage-url]
[![version-img]][version-url]Prometheus metrics for Go `database/sql` via [VictoriaMetrics/metrics](https://github.com/VictoriaMetrics/metrics)
## Features
* Simple API.
* Easy to integrate.## Install
Go version 1.16+
```
go get github.com/cristalhq/sqlmetrics
```## Example
```go
import (
"github.com/VictoriaMetrics/metrics"
"github.com/cristalhq/sqlmetrics"
)// ...
db, err := sql.Open("")
if err != nil {
panic(err)
}ctx := context.Background() // or any other context you have
every := 3 * time.Secondsqlmetrics.NewCollector(ctx, db, every, "label1", "value1", "another", "etc")
// done, db metrics are registered
// you can see them here
w := &bytes.Buffer{}
metrics.WritePrometheus(w, true)
```See this examples: [example_test.go](https://github.com/cristalhq/sqlmetrics/blob/main/example_test.go).
## Documentation
See [these docs][pkg-url].
## License
[MIT License](LICENSE).
[build-img]: https://github.com/cristalhq/sqlmetrics/workflows/build/badge.svg
[build-url]: https://github.com/cristalhq/sqlmetrics/actions
[pkg-img]: https://pkg.go.dev/badge/cristalhq/sqlmetrics
[pkg-url]: https://pkg.go.dev/github.com/cristalhq/sqlmetrics
[reportcard-img]: https://goreportcard.com/badge/cristalhq/sqlmetrics
[reportcard-url]: https://goreportcard.com/report/cristalhq/sqlmetrics
[coverage-img]: https://codecov.io/gh/cristalhq/sqlmetrics/branch/main/graph/badge.svg
[coverage-url]: https://codecov.io/gh/cristalhq/sqlmetrics
[version-img]: https://img.shields.io/github/v/release/cristalhq/sqlmetrics
[version-url]: https://github.com/cristalhq/sqlmetrics/releases