forked from BonnierNews/logstash_exporter
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(ci): bump go version to 1.16 Signed-off-by: brunopadz <[email protected]> * chore(ci): add support for codecov Signed-off-by: brunopadz <[email protected]> * chore(ci): add support to codacy Signed-off-by: brunopadz <[email protected]> * chore(ci): rename code analysis job name Signed-off-by: brunopadz <[email protected]> * chore(ci): run code analysis only on pull requests to main branch Signed-off-by: brunopadz <[email protected]> * feat(ci): add support to goreleaser Signed-off-by: brunopadz <[email protected]> * fix(ci): set right name for github token Signed-off-by: brunopadz <[email protected]> * fix(ci): add github token secret to goreleaser step Signed-off-by: brunopadz <[email protected]> * feat(ci): push docker images to docker hub using build-push-action Signed-off-by: brunopadz <[email protected]> * fix(ci): set which platforms must be built with docker Signed-off-by: brunopadz <[email protected]> * chore(ci): release pipeline must only run for main branch Signed-off-by: brunopadz <[email protected]> * feat: prepare for first release Signed-off-by: brunopadz <[email protected]>
- Loading branch information
Showing
10 changed files
with
238 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: 'Create release' | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
name: "Create release" | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Setup | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
release_branches: main | ||
|
||
- name: Create a GitHub release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.tag_version.outputs.new_tag }} | ||
release_name: ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.tag_version.outputs.changelog }} | ||
|
||
- name: Fetch tags | ||
run: | | ||
git fetch --tags | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: linux/arm64,linux/amd64 | ||
push: true | ||
tags: leroymerlinbr/logstash-exporter:latest,leroymerlinbr/logstash-exporter:${{ steps.tag_version.outputs.new_tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
before: | ||
hooks: | ||
- go mod tidy | ||
builds: | ||
- id: "logstash-exporter" | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
goarm: | ||
- 6 | ||
- 7 | ||
|
||
archives: | ||
- format: zip | ||
name_template: "{{ .ProjectName }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}{{if .Arm}}{{.Arm}}{{end}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
# See: https://hub.docker.com/_/golang/ | ||
FROM golang:1.13 as golang | ||
FROM golang:1.16.7-alpine3.14 as build | ||
|
||
# Fetch the source | ||
RUN go get -u github.com/sequra/logstash_exporter | ||
WORKDIR /src | ||
|
||
# Get dependencies and build! | ||
RUN cd $GOPATH/src/github.com/sequra/logstash_exporter && \ | ||
make | ||
COPY ./ /src/ | ||
|
||
RUN go build -a -tags netgo -o logstash_exporter . | ||
|
||
FROM scratch as final | ||
|
||
LABEL maintainer="[email protected]" | ||
LABEL description="Logstash exporter" | ||
LABEL org.opencontainers.image.authors="LMBR Site Reliability Team <[email protected]>" | ||
LABEL org.opencontainers.image.source="https://github.com/leroy-merlin-br/logstash-exporter" | ||
LABEL org.opencontainers.image.licenses="Copyright © 2021 Leroy Merlin Brasil" | ||
LABEL org.opencontainers.image.vendor="Leroy Merlin Brasil" | ||
|
||
COPY --from=build /src/logstash_exporter / | ||
|
||
# It looks like the `latest` tag uses uclibc | ||
# See: https://hub.docker.com/_/busybox/ | ||
FROM busybox:latest | ||
COPY --from=golang /go/src/github.com/sequra/logstash_exporter/logstash_exporter / | ||
LABEL maintainer [email protected] | ||
EXPOSE 9198 | ||
|
||
ENTRYPOINT ["/logstash_exporter"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,105 @@ | ||
# Logstash exporter [![Build Status](https://travis-ci.org/sequra/logstash_exporter.svg)] | ||
Prometheus exporter for the metrics available in Logstash since version 5.0. | ||
![GitHub](https://img.shields.io/github/license/leroy-merlin-br/logstash-exporter) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/leroy-merlin-br/logstash-exporter) | ||
|
||
Continuous integration: [travis](https://travis-ci.org/sequra/logstash_exporter/) | ||
# logstash-exporter | ||
|
||
## Version compatibility | ||
Exports [Logstash]() metrics to [Prometheus]() for monitoring. | ||
|
||
As logstash can change API metrics in new versions (which happened on v7.3.0), we decided to change the | ||
version of `logstash_exporter` to adapt to the minimum supported version of logstash using the first three numbers for compatibility and the latest one as own increasing version. | ||
## Version compatibility and some important info | ||
|
||
For instance, `logstash_exporter v7.3.0.0` supports a minimum version of logstash 7.3.0, meanwhile `logstash-exporter v5.0.0.0` suppots a minimum version of logstash 5.0. | ||
The exporter only supports Logstash >= v7.3. For earlier versions please check | ||
[sequra/logstash_exporter](https://github.com/sequra/logstash_exporter). | ||
|
||
This change will also be reflected on branch names, existing `master` (the latest supported version), `v7.3.0` (>= logstash 7.3.0), and `v5.0.0` (>= logstash 5.0 and < 7.3.0). | ||
As some may notice, this is exporter is a result of multiple forks, we decided to create another version for a number | ||
of reasons: | ||
- [sequra/logstash_exporter](https://github.com/sequra/logstash_exporter) maintainers doesn't seem to care about the | ||
project anymore. | ||
- This project builds binaries and docker images, eliminating the need for a project like | ||
[bitnami/bitnami-docker-logstash-exporter](https://github.com/bitnami/bitnami-docker-logstash-exporter) which downloads | ||
a binary from [their servers](https://github.com/bitnami/bitnami-docker-logstash-exporter/blob/master/7.3/debian-10/Dockerfile#L12), | ||
which is **super creepy**. | ||
- Bitnami's project doesn't offer a build for other architectures such as `arm64` and here at Leroy Merlin Brasil we | ||
rely heavily on Logstash pods running on Graviton nodes. | ||
|
||
## Usage | ||
## Run | ||
|
||
```bash | ||
go get -u github.com/sequra/logstash_exporter | ||
cd $GOPATH/src/github.com/sequra/logstash_exporter | ||
make | ||
./logstash_exporter --web.listen-address=:1234 --logstash.endpoint="http://localhost:1235" | ||
For pre-built binaries, check the [releases page](https://github.com/leroy-merlin-br/logstash-exporter/releases). | ||
|
||
### Docker | ||
|
||
```sh | ||
docker run leroymerlinbr/logstash_exporter:latest | ||
``` | ||
|
||
### Flags | ||
### CLI | ||
|
||
```sh | ||
logstash_exporter --help | ||
usage: logstash_exporter [<flags>] | ||
|
||
Flags: | ||
-h, --help Show context-sensitive help (also try --help-long and | ||
--help-man). | ||
--logstash.endpoint="http://localhost:9600" | ||
The protocol, host and port on which logstash metrics | ||
API listens | ||
--web.listen-address=":9198" | ||
Address on which to expose metrics and web interface. | ||
--log.level="info" Only log messages with the given severity or above. | ||
Valid levels: [debug, info, warn, error, fatal] | ||
--log.format="logger:stderr" | ||
Set the log target and format. Example: | ||
"logger:syslog?appname=bob&local=7" or | ||
"logger:stdout?json=true" | ||
--version Show application version. | ||
logstash_exporter <flags> | ||
-h, --help Show context-sensitive help (also try --help-long and --help-man). | ||
--logstash.endpoint="http://localhost:9600" | ||
The protocol, host and port on which logstash metrics API listens. | ||
--listen.address=":9198" Address on which to expose metrics and web interface. | ||
--log.level="info" The logging level to be defined. | ||
--version Show application version. | ||
``` | ||
|
||
## Implemented metrics | ||
|
||
* `logstash_exporter_build_info` (gauge) | ||
* `logstash_exporter_scrape_duration_seconds`: logstash_exporter: Duration of a scrape job. (summary) | ||
* `logstash_info_jvm`: A metric with a constant '1' value labeled by name, version and vendor of the JVM running Logstash. (counter) | ||
* `logstash_info_node`: A metric with a constant '1' value labeled by Logstash version. (counter) | ||
* `logstash_info_os`: A metric with a constant '1' value labeled by name, arch, version and available_processors to the OS running Logstash. (counter) | ||
* `logstash_node_gc_collection_duration_seconds_total` (counter) | ||
* `logstash_node_gc_collection_total` (gauge) | ||
* `logstash_node_jvm_threads_count` (gauge) | ||
* `logstash_node_jvm_threads_peak_count` (gauge) | ||
* `logstash_node_mem_heap_committed_bytes` (gauge) | ||
* `logstash_node_mem_heap_max_bytes` (gauge) | ||
* `logstash_node_mem_heap_used_bytes` (gauge) | ||
* `logstash_node_mem_nonheap_committed_bytes` (gauge) | ||
* `logstash_node_mem_nonheap_used_bytes` (gauge) | ||
* `logstash_node_mem_pool_committed_bytes` (gauge) | ||
* `logstash_node_mem_pool_max_bytes` (gauge) | ||
* `logstash_node_mem_pool_peak_max_bytes` (gauge) | ||
* `logstash_node_mem_pool_peak_used_bytes` (gauge) | ||
* `logstash_node_mem_pool_used_bytes` (gauge) | ||
* `logstash_node_pipeline_duration_seconds_total` (counter) | ||
* `logstash_node_pipeline_events_filtered_total` (counter) | ||
* `logstash_node_pipeline_events_in_total` (counter) | ||
* `logstash_node_pipeline_events_out_total` (counter) | ||
* `logstash_node_pipeline_queue_push_duration_seconds_total` (counter) | ||
* `logstash_node_plugin_bulk_requests_failures_total` (counter) | ||
* `logstash_node_plugin_bulk_requests_successes_total` (counter) | ||
* `logstash_node_plugin_bulk_requests_with_errors_total` (counter) | ||
* `logstash_node_plugin_documents_failures_total` (counter) | ||
* `logstash_node_plugin_documents_successes_total` (counter) | ||
* `logstash_node_plugin_duration_seconds_total` (counter | ||
* `logstash_node_plugin_queue_push_duration_seconds_total` (counter) | ||
* `logstash_node_plugin_events_in_total` (counter) | ||
* `logstash_node_plugin_events_out_total` (counter) | ||
* `logstash_node_plugin_current_connections_count` (gauge) | ||
* `logstash_node_plugin_peak_connections_count` (gauge) | ||
* `logstash_node_process_cpu_total_seconds_total` (counter) | ||
* `logstash_node_process_max_filedescriptors` (gauge) | ||
* `logstash_node_process_mem_total_virtual_bytes` (gauge) | ||
* `logstash_node_process_open_filedescriptors` (gauge) | ||
* `logstash_node_queue_events` (counter) | ||
* `logstash_node_queue_size_bytes` (counter) | ||
* `logstash_node_queue_max_size_bytes` (counter) | ||
* `logstash_node_dead_letter_queue_size_bytes` (counter) | ||
* `logstash_node_up`: whether logstash node is up (1) or not (0) (gauge) | ||
|
||
## Integration tests | ||
In order to execute manual integration tests (to know if certain logstash version is compatible with logstash-exporter), you can follow instructions present on file [integration-tests/README.md](integration-tests/README.md). | ||
## Metrics | ||
|
||
| Name | Type | Description | | ||
| --- | --- | --- | | ||
| `logstash_exporter_build_info` | gauge | Exporter build info | | ||
| `logstash_exporter_scrape_duration_seconds` | summary | Duration of a scrape job. | | ||
| `logstash_info_jvm` | counter | A metric with a constant '1' value labeled by name, version and vendor of the JVM running Logstash.| | ||
| `logstash_info_node`| counter | A metric with a constant '1' value labeled by Logstash version. | | ||
| `logstash_info_os` | counter | A metric with a constant '1' value labeled by name, arch, version and available_processors to the OS running Logstash. | | ||
| `logstash_node_gc_collection_duration_seconds_total` | counter | | | ||
| `logstash_node_gc_collection_total` | gauge | | | ||
| `logstash_node_jvm_threads_count` | gauge | | | ||
| `logstash_node_jvm_threads_peak_count` | gauge | | | ||
| `logstash_node_mem_heap_committed_bytes` | gauge | | | ||
| `logstash_node_mem_heap_max_bytes` | gauge | | | ||
| `logstash_node_mem_heap_used_bytes` | gauge | | ||
| `logstash_node_mem_nonheap_committed_bytes` | gauge | | | ||
| `logstash_node_mem_nonheap_used_bytes` | gauge | | | ||
| `logstash_node_mem_pool_committed_bytes` | gauge | | | ||
| `logstash_node_mem_pool_max_bytes` | gauge | | | ||
| `logstash_node_mem_pool_peak_max_bytes` | gauge | | | ||
| `logstash_node_mem_pool_peak_used_bytes` | gauge | | | ||
| `logstash_node_mem_pool_used_bytes` | gauge | | | ||
| `logstash_node_pipeline_duration_seconds_total` | counter | | | ||
| `logstash_node_pipeline_events_filtered_total` | counter | | | ||
| `logstash_node_pipeline_events_in_total` | counter | | | ||
| `logstash_node_pipeline_events_out_total` | counter | | | ||
| `logstash_node_pipeline_queue_push_duration_seconds_total` | counter | | | ||
| `logstash_node_plugin_bulk_requests_failures_total` | counter | | | ||
| `logstash_node_plugin_bulk_requests_successes_total` | counter | | | ||
| `logstash_node_plugin_bulk_requests_with_errors_total` | counter | | | ||
| `logstash_node_plugin_documents_failures_total` | counter | | | ||
| `logstash_node_plugin_documents_successes_total` | counter | | | ||
| `logstash_node_plugin_duration_seconds_total` (| counter | | | ||
| `logstash_node_plugin_queue_push_duration_seconds_total` | counter | | | ||
| `logstash_node_plugin_events_in_total` | counter | | | ||
| `logstash_node_plugin_events_out_total` | counter | | | ||
| `logstash_node_plugin_current_connections_count` | gauge | ||
| `logstash_node_plugin_peak_connections_count` | gauge | ||
| `logstash_node_process_cpu_total_seconds_total` | counter | | | ||
| `logstash_node_process_max_filedescriptors` | gauge | ||
| `logstash_node_process_mem_total_virtual_bytes` | gauge | ||
| `logstash_node_process_open_filedescriptors` | gauge | ||
| `logstash_node_queue_events` | counter | | | ||
| `logstash_node_queue_size_bytes` | counter | | | ||
| `logstash_node_queue_max_size_bytes` | counter | | | ||
| `logstash_node_dead_letter_queue_size_bytes` | counter | | | ||
| `logstash_node_up`: | gauge | whether logstash node is up (1) or not (0) | | ||
|
||
## Contributing | ||
|
||
We welcome any contributions. We appreciate pretty git commit messages such as | ||
[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). | ||
|
||
Please check the [Issues](https://github.com/leroy-merlin-br/logstash-exporter/issues) page for features and bugs that | ||
need some love. | ||
|
||
### Integration tests | ||
|
||
In order to execute manual integration tests (to be sure certain logstash version is compatible with logstash_exporter), | ||
you can follow instructions [here](integration-tests/README.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
codecov: | ||
require_ci_to_pass: yes | ||
|
||
coverage: | ||
precision: 2 | ||
round: down | ||
range: "70...100" | ||
|
||
parsers: | ||
gcov: | ||
branch_detection: | ||
conditional: yes | ||
loop: yes | ||
method: no | ||
macro: no | ||
|
||
comment: | ||
layout: "reach,diff,flags,files,footer" | ||
behavior: default | ||
require_changes: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
Oops, something went wrong.