Documentation ¶
Index ¶
Constants ¶
const ( Name = "snapshooter" Usage = "Take snapshots of Elasticsearch cluster on a schedule, and clean up old ones with downsampling." )
const SnapshotFormat = "snapshooter-2006-01-02t15-04-05"
SnapshotFormat is the format for snapshot names (time.Time.Format()). Elasticsearch snapshot names may not contain spaces.
Variables ¶
var ( // ErrWrongType is returned by RepositoryService.Ensure when the // repository already exists but is of the wrong type. ErrWrongType = goerr.New("repository exists but is the wrong type") )
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { *kingpin.Application // contains filtered or unexported fields }
App holds application state.
func (*App) Main ¶
func (app *App) Main(g prometheus.Gatherer)
Main is the main method of App and should be called in main.main() after flag parsing.
type Flags ¶
type Flags struct { // Snapshot repository to use. Repository Repository // Frequency of snapshots. Config retention.Config // If true, clean up old snapshots. Delete bool // If true, print one cycle of snapshot // creation/deletion and exit without actually // performing any of the actions. DryRun bool *cmd.ElasticsearchFlags *cmd.LoggingFlags *cmd.ServerFlags }
Flags holds command line flags for the snapshooter App.
type Healthchecks ¶
type Healthchecks struct { Handler healthcheck.Handler // Flag to be set true once a connection // to Elasticsearch is successfully established. ElasticSessionCreated bool }
func NewHealthchecks ¶
func NewHealthchecks(r prometheus.Registerer, namespace string) *Healthchecks
type Instrumentation ¶
type Instrumentation struct { // Count of the number of times snapshooter has // polled Elasticsearch for information. Loops prometheus.Counter // Number of seconds spent sleeping. SleepSeconds prometheus.Summary // Number of seconds spent creating snapshots. SnapshotCreationSeconds prometheus.Summary // Number of seconds spent deleting snapshots. SnapshotDeletionSeconds prometheus.Summary // A count of Elasticsearch snapshots created. SnapshotsCreated prometheus.Counter // A count of Elasticsearch snapshots deleted. SnapshotsDeleted prometheus.Counter // A count of Elasticsearch snapshots skipped // because a previous operation was still running. SnapshotsSkipped prometheus.Counter // Number of snapshots in Elasticsearch. Snapshots prometheus.Gauge }
Instrumentation holds Prometheus metrics specific to the snapshooter App.
func NewInstrumentation ¶
func NewInstrumentation(namespace string) *Instrumentation
NewInstrumentation returns a new Metrics.
func (*Instrumentation) Collect ¶
func (m *Instrumentation) Collect(c chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*Instrumentation) Describe ¶
func (m *Instrumentation) Describe(c chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
type Repository ¶
type Repository struct { // The name of the repository. Name string // The type of the repository, such as "fs" or "s3". Type string // Settings for the repository. // Specific settings depend on Type. Settings map[string]string }
Repository represents an Elasticsearch snapshot repository.
See also: https://www.elastic.co/guide/en/elasticsearch/reference/7.0/modules-snapshots.html#_repositories
type RepositoryService ¶
type RepositoryService interface { // Ensure the snapshots repository exists with // given Name and Type. Settings are are not // checked. Returns ErrWrongType if a repository // with the correct Name but wrong Type exists. Ensure(context.Context) error // Create a snapshot named using SnapshotFormat // and the return the time it was created. CreateSnapshot(context.Context) (time.Time, error) // List the snapshots in the repository by time. // Snapshots that don't match SnapshotFormat // are ignored. ListSnapshots(context.Context) ([]time.Time, error) // Deletes a snapshot. DeleteSnapshot(context.Context, time.Time) error }
RepositoryService is an Elasticsearch client specific to a single snapshot repository.
func NewRepositoryService ¶
func NewRepositoryService(c *elastic.Client, r *Repository, dryRun bool) RepositoryService
NewRepositoryService returns a new RepositoryService.