Seeing unrelated debugging messages in your logs?
After a fresh install, Vector comes preconfigured with a Demo logs source. It might be useful for initial testing, but don't forget to remove it afterwards.
How you would like to collect your Prometheus metrics?
Collect metrics from your Prometheus instance using Vector and Prometheus Remote-Write.
Select your platform:
Configure the Vector APT repository and install Vector:
bash -c "$(curl -L https://setup.vector.dev)"
apt-get install vector
Add a Prometheus source and a Better Stack sink to your /etc/vector/vector.yaml
config:
sources:
better_stack_prometheus_source_$SOURCE_TOKEN:
type: "prometheus_remote_write"
address: "0.0.0.0:9090"
transforms:
better_stack_prometheus_log_transform_$SOURCE_TOKEN:
type: "metric_to_log"
inputs:
- "better_stack_prometheus_source_$SOURCE_TOKEN"
better_stack_prometheus_transform_$SOURCE_TOKEN:
type: "remap"
inputs:
- "better_stack_prometheus_log_transform_$SOURCE_TOKEN"
source: |
.dt = del(.timestamp)
string_name = string(.name) ?? ""
if (ends_with(string_name, "_total") || ends_with(string_name, "_sum") || ends_with(string_name, "_counter")) && is_object(.gauge) {
.counter.value = del(.gauge.value)
del(.gauge)
}
sinks:
better_stack_http_sink_$SOURCE_TOKEN:
type: "http"
inputs:
- "better_stack_prometheus_transform_$SOURCE_TOKEN"
uri: "https://in.logs.betterstack.com/metrics"
method: "post"
encoding:
codec: "json"
auth:
strategy: "bearer"
token: "$SOURCE_TOKEN"
[sources.better_stack_prometheus_source_$SOURCE_TOKEN]
type = "prometheus_remote_write"
address = "0.0.0.0:9090"
[transforms.better_stack_prometheus_log_transform_$SOURCE_TOKEN]
type = "metric_to_log"
inputs = ["better_stack_prometheus_source_$SOURCE_TOKEN"]
[transforms.better_stack_prometheus_transform_$SOURCE_TOKEN]
type = "remap"
inputs = [ "better_stack_prometheus_log_transform_$SOURCE_TOKEN" ]
source = '''
.dt = del(.timestamp)
string_name = string(.name) ?? ""
if (ends_with(string_name, "_total") || ends_with(string_name, "_sum") || ends_with(string_name, "_counter")) && is_object(.gauge) {
.counter.value = del(.gauge.value)
del(.gauge)
}
'''
[sinks.better_stack_http_sink_$SOURCE_TOKEN]
type = "http"
inputs = [ "better_stack_prometheus_transform_$SOURCE_TOKEN" ]
uri = "https://in.logs.betterstack.com/metrics"
method = "post"
encoding.codec = "json"
auth.strategy = "bearer"
auth.token = "$SOURCE_TOKEN"
Add a remote_write
section to your Prometheus config file:
remote_write:
- url: 'http://localhost:9090'
Reload the configuration of your Prometheus server:
ps -A | grep prometheus | tr -s ' ' | xargs | cut -f1 -d' ' | xargs kill -HUP
Restart Vector to reload the configuration:
systemctl restart vector
You should see your metrics in the Prometheus dashboard.
Seeing unrelated debugging messages in your logs?
After a fresh install, Vector comes preconfigured with a Demo logs source. It might be useful for initial testing, but don't forget to remove it afterwards.
Does the Prometheus dashboard show unexpected results?
We recommend setting up Node Exporter if you want to use our Prometheus dashboard since it expects to see metrics collected from Node Exporter.
Forward metrics from your Prometheus exporters and applications using Vector.
Select your platform:
Configure the Vector APT repository and install Vector:
bash -c "$(curl -L https://setup.vector.dev)"
apt-get install vector
Add a Prometheus source and a Better Stack sink to your /etc/vector/vector.yaml
config.
Change endpoints
in the source section to be an array of string URLs on which Vector can scrape metrics in the Prometheus format.
sources:
better_stack_prometheus_source_$SOURCE_TOKEN:
type: "prometheus_scrape"
endpoints:
- "<REPLACE_BY_URLS_FOR_SCRAPING>"
instance_tag: "instance"
scrape_interval_secs: 30
transforms:
better_stack_prometheus_log_transform_$SOURCE_TOKEN:
type: "metric_to_log"
inputs:
- "better_stack_prometheus_source_$SOURCE_TOKEN"
better_stack_prometheus_transform_$SOURCE_TOKEN:
type: "remap"
inputs:
- "better_stack_prometheus_log_transform_$SOURCE_TOKEN"
source: |
.dt = del(.timestamp)
sinks:
better_stack_http_sink_$SOURCE_TOKEN:
type: "http"
inputs:
- "better_stack_prometheus_transform_$SOURCE_TOKEN"
uri: "https://in.logs.betterstack.com/metrics"
method: "post"
encoding:
codec: "json"
auth:
strategy: "bearer"
token: "$SOURCE_TOKEN"
[sources.better_stack_prometheus_source_$SOURCE_TOKEN]
type = "prometheus_scrape"
endpoints = ["<REPLACE_BY_URLS_FOR_SCRAPING>"]
instance_tag = "instance"
scrape_interval_secs = 30
[transforms.better_stack_prometheus_log_transform_$SOURCE_TOKEN]
type = "metric_to_log"
inputs = ["better_stack_prometheus_source_$SOURCE_TOKEN"]
[transforms.better_stack_prometheus_transform_$SOURCE_TOKEN]
type = "remap"
inputs = [ "better_stack_prometheus_log_transform_$SOURCE_TOKEN" ]
source = '''
.dt = del(.timestamp)
'''
[sinks.better_stack_http_sink_$SOURCE_TOKEN]
type = "http"
inputs = [ "better_stack_prometheus_transform_$SOURCE_TOKEN" ]
uri = "https://in.logs.betterstack.com/metrics"
method = "post"
encoding.codec = "json"
auth.strategy = "bearer"
auth.token = "$SOURCE_TOKEN"
Restart Vector to reload the configuration:
systemctl restart vector
You should see your metrics in the Prometheus dashboard.
Seeing unrelated debugging messages in your logs?
After a fresh install, Vector comes preconfigured with a Demo logs source.
It might be useful for initial testing, but don't forget to remove it afterwards.
Does the Prometheus dashboard show unexpected results?
We recommend setting up Node Exporter if you want to use our Prometheus dashboard since it expects to see metrics collected from Node Exporter.
Please let us know at hello@betterstack.com.
We're happy to help! 🙏