Sensu-go: Spike: invent store interface for cluster metrics

Created on 27 Nov 2019  路  3Comments  路  Source: sensu/sensu-go

As a Sensu Backend, I would like to be able to know key metrics about the cluster I am a member of.

This includes:

  • Total events
  • Events by incident level (0, 1, 2, 3+)
  • Total Entities
  • Entities by class
  • Total Keepalives
  • Failing vs Passing Keepalives

The spike should include analysis of the etcd and postgres event stores.

The result of the spike should be a Go interface that specifies how a user would query the store for information about these things.

spike

Most helpful comment

@portertech you've been waiting patiently for 29 days, and now you've got your answer: Yes!

All 3 comments

I've created three interfaces and structured datatypes for getting metrics information for the Event, Entity, and Keepalive resource types.

package store

import "context"

// EventGauges are gauge metrics about the events stored in Sensu.
type EventGauges struct {
    Total    int64
    Passing  int64
    Warning  int64
    Critical int64
    Other    int64
}

// EntityGauges are gauge metrics about the entities stored in Sensu.
type EntityGauges struct {
    Total int64
    Agent int64
    Proxy int64
}

// KeepaliveGauges are gauge metrics about the keepalives stored in Sensu.
type KeepaliveGauges struct {
    Total   int64
    Passing int64
    Failing int64
}

// EventMetrics provides a way to get metrics about Sensu events.
type EventMetrics interface {
    // GetEventGauges gets gauge metrics about events.
    GetEventGauges(context.Context) (EventGauges, error)
}

// EntityMetrics provides a way to get metrics about Sensu entities.
type EntityMetrics interface {
    // GetEntityGauges gets gauge metrics about entities.
    GetEntityGauges(context.Context) (EntityGauges, error)
}

// KeepaliveMetrics provides a way to get metrics about Sensu keepalives.
type KeepaliveMetrics interface {
    // GetKeepaliveGauges gets gauge metrics about keepalives.
    GetKeepaliveGauges(context.Context) (KeepaliveGauges, error)
}

Using three interfaces instead of one will help with separation of concerns, and will also keep the disparity between postgres and etcd out of our way.

The Gauge data types can be extended later without affecting compatibility.

Does this interface account for per namespace scopes?

@portertech you've been waiting patiently for 29 days, and now you've got your answer: Yes!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

palourde picture palourde  路  5Comments

nikkictl picture nikkictl  路  4Comments

craigpfeiffer picture craigpfeiffer  路  3Comments

palourde picture palourde  路  3Comments

jamesdphillips picture jamesdphillips  路  4Comments