Documentation
¶
Overview ¶
Package checker implements a dummy checker for happyDomain.
This is an educational example that demonstrates all the building blocks needed to create a happyDomain checker. It performs no real monitoring; instead, it returns a configurable message and a random score, so you can focus on the structure without worrying about external dependencies.
Index ¶
Constants ¶
const ObservationKeyDummy = "dummy"
ObservationKeyDummy is the unique key that identifies observations produced by this checker. Every checker must define at least one key so happyDomain can store and retrieve its data.
Variables ¶
var Version = "built-in"
Version is the checker version reported in CheckerDefinition.Version.
It defaults to "built-in", which is appropriate when the checker package is imported directly (built-in or plugin mode). Standalone binaries (like main.go) should override this from their own Version variable at the start of main(), which makes it easy for CI to inject a version with a single -ldflags "-X main.Version=..." flag instead of targeting the nested package path.
Functions ¶
func Definition ¶
func Definition() *sdk.CheckerDefinition
Definition returns the CheckerDefinition for the dummy checker.
A CheckerDefinition tells happyDomain everything it needs to know about your checker: its identity, where it can be applied, what options it accepts, what rules it provides, and how often it should run.
func Provider ¶
func Provider() sdk.ObservationProvider
Provider returns a new dummy observation provider.
The provider is the central object of a checker. It implements the ObservationProvider interface (required) and can optionally implement additional interfaces to unlock more features:
- CheckerDefinitionProvider → exposes /definition and /evaluate endpoints
- CheckerMetricsReporter → exposes /report (JSON metrics) endpoint
- CheckerHTMLReporter → exposes /report (HTML) endpoint
In this example, the provider implements all three optional interfaces so you can see how each one works.
Types ¶
type DummyData ¶
type DummyData struct {
// Message is an arbitrary string returned as part of the observation.
Message string `json:"message"`
// Score is a number between 0 and 100. The evaluation rules compare it
// against user-defined thresholds to determine the check status.
Score float64 `json:"score"`
// CollectedAt records when the observation was taken. It is used by the
// metrics reporter to timestamp the extracted metrics.
CollectedAt time.Time `json:"collected_at"`
}
DummyData is the data structure returned by Collect.
When happyDomain collects an observation, it serialises this struct to JSON and stores it. Later, during evaluation, the same JSON is deserialised back into this struct. Design this type to hold everything your rules will need to decide OK / Warning / Critical.
Source Files
¶
- collect.go
- definition.go
- provider.go
- rule.go
- types.go