2017-01-02 21:18:06 +01:00
[](https://travis-ci.org/Icinga/icingabeat)
2017-01-02 15:44:34 +01:00
2016-12-02 11:51:44 +01:00
# Icingabeat
2017-03-15 11:37:28 +01:00
2017-02-01 16:55:48 +01:00
> The Beats are lightweight data shippers, written in Go, that you install on
> your servers to capture all sorts of operational data (think of logs,
> metrics, or network packet data). The Beats send the operational data to
> Elasticsearch, either directly or via Logstash, so it can be visualized with
> Kibana.
2016-12-02 11:51:44 +01:00
2017-03-15 11:37:28 +01:00
Icingabeat is an [Elastic Beat ](https://www.elastic.co/products/beats ) that
fetches data from the Icinga 2 API and sends it either directly to Elasticsearch
or Logstash. This Beat supports two modes:
## Eventstream
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
Receive an eventstream from the Icinga 2 API. This stream includes events such
as checkresults, notifications, downtimes, acknowledgemts and many other types.
See below for details. There is no polling involved when receiving an
eventstream.
2017-01-02 12:02:47 +01:00
Example usage:
* Correlate monitoring data with logging information
* Monitor notifications sent by Icinga 2
2017-03-15 11:37:28 +01:00
## Statuspoller
The Icinga 2 API exports a lot of information about the state of the Icinga
daemon. Icingabeat can poll these information periodically.
2017-01-02 12:02:47 +01:00
Example usage:
2017-03-15 11:37:28 +01:00
* Visualize metrics of the Icinga 2 daemon
* Get insights how each enable Icinga 2 feature performs
2017-01-02 12:02:47 +01:00
* Information about zones and endpoints
2016-12-02 11:51:44 +01:00
2017-03-15 11:37:28 +01:00
### Installation
Download and install your package from the
[latest release ](https://github.com/Icinga/icingabeat/releases/latest ) page.
2016-12-02 11:51:44 +01:00
2017-03-15 11:37:28 +01:00
### Configuration
Configuration of Icingabeat is splitted into 3 sections: General, Evenstream and
Statuspoller. On Linux configuration files are located at `/etc/icingabeat`
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
#### General
Settings in this section apply to both modes.
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
##### `host`
Hostname of Icinga 2 API. This can be either an IP address or domain.
2017-01-02 12:02:47 +01:00
Defaults to `localhost`
2017-03-15 11:37:28 +01:00
##### `port`
2017-01-02 12:02:47 +01:00
Defaults to `5665`
2017-03-15 11:37:28 +01:00
##### `user`
Username to be used for the API connection. You need to create this user in your Icinga 2 configuration. Make sure that it has sufficient permissions to read the
data you want to collect.
Here is an example how an API user in your Icinga 2 configuration:
2017-01-02 12:02:47 +01:00
2017-01-02 12:26:55 +01:00
```c++
2017-01-02 12:02:47 +01:00
object ApiUser "icinga" {
password: "icinga"
permissions = ["events/*", "status/query"]
}
```
2017-03-15 11:37:28 +01:00
Learn more about the `ApiUser` and its permissions in the
[Icinga 2 docs ](https://docs.icinga.com/icinga2/latest/doc/module/icinga2/chapter/icinga2-api#icinga2-api-permissions ).
##### `password`
2017-01-02 12:02:47 +01:00
Defaults to `icinga`
2017-03-15 11:37:28 +01:00
##### `skip_ssl_verify`
2017-01-03 09:34:48 +01:00
Skip verification of SSL certificates. Defaults to `false`
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
#### Eventstream
Settings in this section apply to the eventstream mode. To disable the
eventstream completely, comment out the section.
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
##### `types`
You can select which particular Icinga 2 events you want to receive and store.
The following types are available, you must set at least one:
2016-12-02 11:51:44 +01:00
2017-03-15 11:37:28 +01:00
* `CheckResult`
* `StateChange`
* `Notification`
* `AcknowledgementSet`
* `AcknowledgementCleared`
* `CommentAdded`
* `CommentRemoved`
* `DowntimeAdded`
* `DowntimeRemoved`
* `DowntimeStarted`
* `DowntimeTriggered`
2016-12-02 11:51:44 +01:00
2017-03-15 11:37:28 +01:00
To set multiple types, do the following:
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
```yaml
types:
- CheckResult
- StateChange
- Notification
- AcknowledgementSet
- AcknowledgementCleared
```
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
##### `filter`
Additionally to selecting the types of events, you can filter them by
2017-03-15 11:42:57 +01:00
attributes using the prefix `event.` . By default no filter is set.
2017-03-15 11:37:28 +01:00
###### Examples
Only checkresults with the exit code 2:
2017-01-02 12:26:55 +01:00
```yaml
2017-03-15 11:37:28 +01:00
filter: "event.check_result.exit_status==2"
2016-12-02 11:51:44 +01:00
```
2017-03-15 11:37:28 +01:00
Only checkreults of services that match `mysql*` :
2017-01-02 12:26:55 +01:00
```yaml
2017-03-15 11:37:28 +01:00
filter: 'match("mysql*", event.service)'
2017-01-02 12:02:47 +01:00
```
2016-12-02 11:51:44 +01:00
2017-03-15 11:37:28 +01:00
##### `retry_interval`
On a connection loss Icingabeat will try to reconnect to the API periodically.
This setting defines the interval for connection retries. Defaults to `10s`
2017-01-18 16:54:49 +01:00
2017-03-15 11:37:28 +01:00
#### Statuspoller
Settings of this section apply to the statuspoller mode.
2017-01-03 16:36:39 +01:00
2017-03-15 11:37:28 +01:00
##### `interval`
2017-01-03 16:36:39 +01:00
Interval at which the status API is called. Set to `0` to disable polling.
Defaults to `60s`
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
### Run
2017-03-15 11:42:57 +01:00
On Linux systems, use one of the following commands to start Icingabeat:
2017-03-15 11:37:28 +01:00
* `service icingabeat start`
* `systemctl icingabeat start` or
* `/etc/init.d/icingabeat start`
2016-12-02 11:51:44 +01:00
2017-02-01 16:11:32 +01:00
## Fields
2017-01-02 17:22:45 +01:00
Icingabeat exports a bunch of fields. Have a look to the
[fields.asciidoc ](docs/fields.asciidoc ) for details.
2017-03-15 11:37:28 +01:00
## Development
### Building and running manually
2017-01-02 12:02:47 +01:00
2017-03-15 11:37:28 +01:00
#### Requirements
2017-01-02 12:02:47 +01:00
* [Golang ](https://golang.org/dl/ ) 1.7
2017-03-15 11:37:28 +01:00
#### Clone
2017-01-02 12:02:47 +01:00
To clone Icingabeat from the git repository, run the following commands:
2017-01-02 12:26:55 +01:00
```shell
2017-01-02 12:02:47 +01:00
mkdir -p ${GOPATH}/github.com/icinga
cd ${GOPATH}/github.com/icinga
git clone https://github.com/icinga/icingabeat
```
2016-12-02 11:51:44 +01:00
For further development, check out the [beat developer guide ](https://www.elastic.co/guide/en/beats/libbeat/current/new-beat.html ).
2017-03-15 11:37:28 +01:00
#### Build
2017-01-02 12:02:47 +01:00
Ensure that this folder is at the following location:
`${GOPATH}/github.com/icinga`
2016-12-02 11:51:44 +01:00
2017-01-02 12:02:47 +01:00
To build the binary for Icingabeat run the command below. This will generate a
binary in the same directory with the name icingabeat.
2016-12-02 11:51:44 +01:00
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make
```
2017-03-15 11:37:28 +01:00
#### Run
2016-12-02 11:51:44 +01:00
To run Icingabeat with debugging output enabled, run:
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
./icingabeat -c icingabeat.yml -e -d "*"
```
2017-03-15 11:37:28 +01:00
#### Test
2016-12-02 11:51:44 +01:00
To test Icingabeat, run the following command:
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make testsuite
```
alternatively:
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make unit-tests
make system-tests
make integration-tests
make coverage-report
```
The test coverage is reported in the folder `./build/coverage/`
2017-03-15 11:37:28 +01:00
#### Update
2016-12-02 11:51:44 +01:00
2017-01-02 12:02:47 +01:00
Each beat has a template for the mapping in elasticsearch and a documentation
for the fields which is automatically generated based on `etc/fields.yml` .
2016-12-02 11:51:44 +01:00
To generate etc/icingabeat.template.json and etc/icingabeat.asciidoc
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make update
```
2017-03-15 11:37:28 +01:00
#### Cleanup
2016-12-02 11:51:44 +01:00
To clean Icingabeat source code, run the following commands:
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make fmt
make simplify
```
To clean up the build directory and generated artifacts, run:
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make clean
```
2017-03-15 11:37:28 +01:00
### Packaging
2016-12-02 11:51:44 +01:00
2017-01-02 12:02:47 +01:00
The beat frameworks provides tools to crosscompile and package your beat for
different platforms. This requires [docker ](https://www.docker.com/ ) and
vendoring as described above. To build packages of your beat, run the following
command:
2016-12-02 11:51:44 +01:00
2017-01-02 12:26:55 +01:00
```shell
2016-12-02 11:51:44 +01:00
make package
```
2017-01-02 12:02:47 +01:00
This will fetch and create all images required for the build process. The hole
process to finish can take several minutes.
2017-03-15 11:37:28 +01:00
To disable snapshot packages or build specific packages, set the following
environment variables:
```shell
export SNAPSHOT=false
export TARGETS="\"linux/amd64 linux/386\""
export PACKAGES=icingabeat/deb
make package
```