Datastore

Event storage

Sensu stores the most recent event for each entity and check pair using an embedded etcd (default) or an external etcd instance. You can access event data using the dashboard events page, sensuctl event commands, and the events API. For longer retention of event data, we recommend integrating Sensu with a time series database, like InfluxDB, or a searchable index, like ElasticSearch or Splunk.

Scaling event storage

LICENSED TIER: Unlock enterprise-scale event storage in Sensu Go with a Sensu license. To activate your license, see the getting started guide.

Sensu supports using an external PostgreSQL instance for event storage in place of etcd. PostgreSQL can handle significantly higher volumes of Sensu events, letting you scale Sensu beyond etcd’s 8GB limit.

Configured with a PostgreSQL event store, Sensu connects to PostgreSQL to store and retrieve event data in place of etcd, while etcd continues to store Sensu entity and configuration data. You can access event data stored in PostgreSQL using the same Sensu web UI, API, and sensuctl processes as etcd-stored events.

Requirements

Sensu supports PostgreSQL 9.5 and later, including Amazon Relational Database Service (Amazon RDS) when configured with the PostgreSQL engine. See the PostgreSQL docs to install and configure PostgreSQL.

Configuration

At the time of enabling the PostgreSQL event store, event data cuts over from etcd to PostgreSQL, resulting in a loss of recent event history. No restarts or Sensu backend configuration changes are required to enable the PostgreSQL event store.

After installing and configuring PostgreSQL, configure Sensu by creating a PostgresConfig resource. See the specification for more information.

type: PostgresConfig
api_version: store/v1
metadata:
  name: my-postgres
spec:
  dsn: "postgresql://user:secret@host:port/dbname"
  pool_size: 20
{
  "type": "PostgresConfig",
  "api_version": "store/v1",
  "metadata": {
    "name": "my-postgres"
  },
  "spec": {
    "dsn": "postgresql://user:secret@host:port/dbname",
    "pool_size": 20
  }
}

With the PostgresConfig resource definition saved to a file (for example: postgres.yml), use sensuctl, configured as the admin user, to activate the PostgreSQL event store.

sensuctl create --file postgres.yml

At this time, there is no supported method for viewing a PostgresConfig resource. To update your Sensu PostgreSQL configuration, repeat the sensuctl create process shown above. You can expect to see PostgreSQL status updates and error messages in the Sensu backend logs at the warn and error log levels, respectively.

Disabling the PostgreSQL event store

To disable the PostgreSQL event store, use sensuctl delete with your PostgresConfig resource definition:

sensuctl delete --file postgres.yml

When disabling the PostgreSQL event store, event data cuts over from PostgreSQL to etcd, resulting in a loss of recent event history. No restarts or Sensu backend configuration changes are required to disable the PostgreSQL event store.

Specification

Top-level attributes

type
description Top-level attribute specifying the sensuctl create resource type. PostgreSQL datastore configs should always be of type PostgresConfig.
required true
type String
example
type: PostgresConfig
api_version
description Top-level attribute specifying the Sensu API group and version. For PostgreSQL datastore configs, this attribute should be store/v1.
required true
type String
example
api_version: store/v1
metadata
description Top-level scope containing the PostgreSQL datastore name.
required true
type Map of key-value pairs
example
metadata:
  name: my-postgres
spec
description Top-level map that includes the PostgreSQL datastore config spec attributes.
required true
type Map of key-value pairs
example
spec:
  dsn: "postgresql://user:secret@host:port/dbname"
  pool_size: 20

Metadata attributes

name
description The PostgreSQL datastore name used internally by Sensu
required true
type String
example
name: my-postgres

Spec attributes

dsn
description Use the dsn attribute to specify the data source names as a URL or PostgreSQL connection string. See the PostgreSQL docs for more information about connection strings.
required true
type String
example
dsn: "postgresql://user:secret@host:port/dbname"
pool_size
description The maximum number of connections to hold in the PostgreSQL connection pool. We recommend 20 for most instances.
required false
default 0 (unlimited)
type Integer
example
pool_size: 20