-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add readme for metrics module #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
| # Export Metrics | ||
|
|
||
| Metrics monitoring is a critical component for ensuring optimal ingester performance and reliability. It provides: | ||
|
|
||
| - Real-time visibility into ingester health and performance | ||
| - Proactive monitoring capabilities for maintaining system stability | ||
| - Rapid troubleshooting and issue resolution | ||
|
|
||
| For detailed information about available metrics, including descriptions and usage guidelines, see our [comprehensive metrics documentation](../docs/metrics-display.md#list-of-metrics-constantly-updated). | ||
|
|
||
| ## Start Metrics Exporter | ||
|
|
||
| To start an HTTP server that serves Prometheus metrics, initialize the metrics exporter before starting the GreptimeDB ingester: | ||
|
|
||
| ```java | ||
| MetricsExporter metricsExporter = new MetricsExporter(MetricsUtil.metricRegistry()); | ||
| metricsExporter.init(ExporterOptions.newDefault()); | ||
| // Start GreptimeDB ingester | ||
| // ... | ||
| ``` | ||
|
|
||
| ## Get Metrics | ||
|
|
||
| You can check the output of `curl http://<host>:<port>/metrics` by getting the latest metrics of the ingester. | ||
|
|
||
| ## Export Metrics to Prometheus | ||
|
|
||
| The ingester supports exporting metrics to Prometheus. Before configuring export of metrics, you need to setup Prometheus by following their official [documentation](https://prometheus.io/docs/prometheus/latest/installation/). | ||
|
|
||
| To scrape metrics from the ingester, write a Prometheus configuration file and save it as `prometheus.yml`: | ||
|
|
||
| ```yaml | ||
| global: | ||
| scrape_interval: 15s | ||
|
|
||
| scrape_configs: | ||
| - job_name: 'greptimedb ingester' | ||
| static_configs: | ||
| # Assuming that the ingester is running locally. | ||
| # The default HTTP port of 8090. | ||
| - targets: ['localhost:8090'] | ||
| ``` | ||
|
|
||
| Start Prometheus using the configuration file: | ||
|
|
||
| ```bash | ||
| ./prometheus --config.file=prometheus.yml | ||
| ``` | ||
|
|
||
| ## Grafana Dashboard | ||
|
|
||
| You can import dashboard via JSON model: [`greptimedb-ingester-dashboard.json`](../grafana/greptimedb-ingester-dashboard.json) | ||
64 changes: 64 additions & 0 deletions
64
ingester-prometheus-metrics/src/main/java/io/greptime/metrics/ExporterOptions.java
This file contains hidden or 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,64 @@ | ||
| /* | ||
| * Copyright 2023 Greptime Team | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.greptime.metrics; | ||
|
|
||
| import io.greptime.common.Copiable; | ||
| import io.greptime.common.Endpoint; | ||
|
|
||
| /** | ||
| * Exporter options. | ||
| */ | ||
| public class ExporterOptions implements Copiable<ExporterOptions> { | ||
| private Endpoint bind_addr; | ||
| private boolean deamon; | ||
|
|
||
| public static ExporterOptions newDefault() { | ||
| ExporterOptions opts = new ExporterOptions(); | ||
| opts.bind_addr = new Endpoint("0.0.0.0", 8090); | ||
| opts.deamon = true; | ||
| return opts; | ||
| } | ||
|
|
||
| public Endpoint getBindAddr() { | ||
| return bind_addr; | ||
| } | ||
|
|
||
| public void setBindAddr(Endpoint bind_addr) { | ||
| this.bind_addr = bind_addr; | ||
| } | ||
|
|
||
| public boolean isDeamon() { | ||
| return deamon; | ||
| } | ||
|
|
||
| public void setDeamon(boolean deamon) { | ||
| this.deamon = deamon; | ||
| } | ||
|
|
||
| @Override | ||
| public ExporterOptions copy() { | ||
| ExporterOptions opts = new ExporterOptions(); | ||
| opts.bind_addr = this.bind_addr; | ||
| opts.deamon = this.deamon; | ||
| return opts; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "ExporterOptions{" + "bind_addr=" + bind_addr + ", deamon=" + deamon + '}'; | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.