Commit aceee04a authored by Julius Volz's avatar Julius Volz

Merge pull request #89 from prometheus/fabxc/getstarted

Adjust getting started section to new config format
parents a40ad094 f7334349
...@@ -22,7 +22,7 @@ git clone https://github.com/prometheus/prometheus.git ...@@ -22,7 +22,7 @@ git clone https://github.com/prometheus/prometheus.git
## Building Prometheus ## Building Prometheus
Building Prometheus currently still requires a `make` step, as some parts of Building Prometheus currently still requires a `make` step, as some parts of
the source are autogenerated (protobufs, web assets, lexer/parser files). the source are autogenerated (web assets).
```language-bash ```language-bash
cd prometheus cd prometheus
...@@ -44,43 +44,35 @@ manner about itself, it may also be used to scrape and monitor its own health. ...@@ -44,43 +44,35 @@ manner about itself, it may also be used to scrape and monitor its own health.
While a Prometheus server which collects only data about itself is not very While a Prometheus server which collects only data about itself is not very
useful in practice, it is a good starting example. Save the following basic useful in practice, it is a good starting example. Save the following basic
Prometheus configuration as a file named `prometheus.conf`: Prometheus configuration as a file named `prometheus.yml`:
``` ```
# Global default settings. global:
global: { scrape_interval: 15s # By default, scrape targets every 15 seconds.
scrape_interval: "15s" # By default, scrape targets every 15 seconds. evaluation_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: "15s" # By default, evaluate rules every 15 seconds. # scrape_timeout is set to the global default (10s).
# Attach these extra labels to all time series collected by this Prometheus instance. # Attach these extra labels to all timeseries collected by this Prometheus instance.
labels: { labels:
label: { monitor: 'codelab-monitor'
name: "monitor"
value: "tutorial-monitor" # A scrape configuration containing exactly one endpoint to scrape:
} # Here it's Prometheus itself.
} scrape_configs:
} # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# A job definition containing exactly one endpoint to scrape: Prometheus itself.
job: { # Override the global default and scrape targets from this job every 5 seconds.
# The job name is added as a label `job={job-name}` to any time series scraped from this job. scrape_interval: 5s
name: "prometheus" scrape_timeout: 10s
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: "5s" target_groups:
- targets: ['localhost:9090']
# Let's define a group of static targets to scrape for this job. In this
# case, only one.
target_group: {
# These endpoints are scraped via HTTP.
target: "http://localhost:9090/metrics"
}
}
``` ```
Prometheus configuration is supplied in an ASCII form of [protocol For a complete specification of configuration options, see the
buffers](https://developers.google.com/protocol-buffers/docs/overview/). The [configuration documentation](/docs/operating/configuration).
[schema definition](https://github.com/prometheus/prometheus/blob/master/config/config.proto)
has a complete documentation of all available configuration options.
## Starting Prometheus ## Starting Prometheus
...@@ -90,7 +82,7 @@ Prometheus build directory and run: ...@@ -90,7 +82,7 @@ Prometheus build directory and run:
```language-bash ```language-bash
# Start Prometheus. # Start Prometheus.
# By default, Prometheus stores its database in /tmp/metrics (flag -storage.local.path). # By default, Prometheus stores its database in /tmp/metrics (flag -storage.local.path).
./prometheus -config.file=prometheus.conf ./prometheus -config.file=prometheus.yml
``` ```
Prometheus should start up and it should show a status page about itself at Prometheus should start up and it should show a status page about itself at
...@@ -107,7 +99,7 @@ environment variable to a value similar to the number of available CPU ...@@ -107,7 +99,7 @@ environment variable to a value similar to the number of available CPU
cores: cores:
```language-bash ```language-bash
GOMAXPROCS=8 ./prometheus -config.file=prometheus.conf GOMAXPROCS=8 ./prometheus -config.file=prometheus.yml
``` ```
Blindly setting `GOMAXPROCS` to a high value can be Blindly setting `GOMAXPROCS` to a high value can be
...@@ -201,36 +193,26 @@ endpoints to a single job, adding extra labels to each group of targets. In ...@@ -201,36 +193,26 @@ endpoints to a single job, adding extra labels to each group of targets. In
this example, we will add the `group="production"` label to the first group of this example, we will add the `group="production"` label to the first group of
targets, while adding `group="canary"` to the second. targets, while adding `group="canary"` to the second.
To achieve this, add the following job definition to your `prometheus.conf` and To achieve this, add the following job definition to your `prometheus.yml` and
restart your Prometheus instance: restart your Prometheus instance:
``` ```
job: { scrape_configs:
name: "example-random" - job_name: 'example-random'
scrape_interval: "5s" scrape_interval: 5s
# The "production" targets for this job. # Override the global default and scrape targets from this job every 5 seconds.
target_group: { scrape_interval: 5s
target: "http://localhost:8080/metrics" scrape_timeout: 10s
target: "http://localhost:8081/metrics"
labels: { target_groups:
label: { - targets: ['localhost:8080', 'localhost:8081']
name: "group" labels:
value: "production" group: 'production'
}
} - targets: ['localhost:8082']
} labels:
# The "canary" targets for this job. group: 'canary'
target_group: {
target: "http://localhost:8082/metrics"
labels: {
label: {
name: "group"
value: "canary"
}
}
}
}
``` ```
Go to the expression browser and verify that Prometheus now has information Go to the expression browser and verify that Prometheus now has information
...@@ -263,52 +245,38 @@ job_service:rpc_durations_microseconds_count:avg_rate5m = avg(rate(rpc_durations ...@@ -263,52 +245,38 @@ job_service:rpc_durations_microseconds_count:avg_rate5m = avg(rate(rpc_durations
``` ```
To make Prometheus pick up this new rule, add a `rule_files` statement to the To make Prometheus pick up this new rule, add a `rule_files` statement to the
global configuration section in your `prometheus.conf`. The config should now global configuration section in your `prometheus.yml`. The config should now
look like this: look like this:
``` ```
# Global default settings. global:
global: { scrape_interval: 15s # By default, scrape targets every 15 seconds.
scrape_interval: "15s" # By default, scrape targets every 15 seconds. evaluation_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: "15s" # By default, evaluate rules every 15 seconds. # scrape_timeout is set to the global default (10s).
# Attach these extra labels to all time series collected by this Prometheus instance. # Attach these extra labels to all timeseries collected by this Prometheus instance.
labels: { labels:
label: { monitor: 'codelab-monitor'
name: "monitor"
value: "tutorial-monitor" rule_files:
} - 'prometheus.rules'
}
# Load and evaluate rules in this file every 'evaluation_interval' seconds. This field may be repeated. scrape_configs:
rule_file: "prometheus.rules" - job_name: 'example-random'
} scrape_interval: 5s
job: { # Override the global default and scrape targets from this job every 5 seconds.
name: "example-random" scrape_interval: 5s
scrape_interval: "5s" scrape_timeout: 10s
# The "production" targets for this job. target_groups:
target_group: { - targets: ['localhost:8080', 'localhost:8081']
target: "http://localhost:8080/metrics" labels:
target: "http://localhost:8081/metrics" group: 'production'
labels: {
label: { - targets: ['localhost:8082']
name: "group" labels:
value: "production" group: 'canary'
}
}
}
# The "canary" targets for this job.
target_group: {
target: "http://localhost:8082/metrics"
labels: {
label: {
name: "group"
value: "canary"
}
}
}
}
``` ```
Restart Prometheus with the new configuration and verify that a new time series Restart Prometheus with the new configuration and verify that a new time series
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment