forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it possible to have metricset specific metrics (elastic#6836)
So far for metricsets and modules only combined metrics were collected. There was no visibility into a single metricset. This PR provides the base functionality to use have each metricset provide it's own metrics. The BaseMetricSet was extended with an `ID()` and `Metrics()` method. The id is required to have a unique identifier for each metricset during reporting and the `Metrics()` method can be used inside each Mmetricsetetricset to access the metricset specific registry. Currently the data collected from all metricsets are exposed under `/dataset`. This is probably going to change and is mainly to show case the first implementation. The data exposed looks as following: ``` { "05d4bd84-2ca2-4d9d-862d-c7822b4389f5": { "id": "05d4bd84-2ca2-4d9d-862d-c7822b4389f5", "metricset": "process_summary", "module": "system", "starttime": "2018-04-17 15:41:34.154435426 +0200 CEST m=+10.037457766" }, "2f85ed18-343b-4c33-865c-44e624cdaf6d": { "id": "2f85ed18-343b-4c33-865c-44e624cdaf6d", "metricset": "load", "module": "system", "starttime": "2018-04-17 15:41:34.15164335 +0200 CEST m=+10.034665690" } } ``` The initial idea was to expose an array instead of map with unique keys. But having a map with unique keys makes it easier to add and remove registries when a metricset runner is started / stopped and the functionality already existed. In case the above metrics were reported to Elasticsearch, each block would be one event. To automate this conversion, we could use a flag on a registry to potential have a different reporting for Elasticsearch. The concept of namespaces was added to manage the existing registries instead of just having on global (`Default`). This can be used in the future for additional API endpoints.
- Loading branch information
1 parent
fb84ad3
commit bc4b07c
Showing
7 changed files
with
106 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package monitoring | ||
|
||
var namespaces = map[string]*Namespace{} | ||
|
||
// Namespace contains the name of the namespace and it's registry | ||
type Namespace struct { | ||
name string | ||
registry *Registry | ||
} | ||
|
||
func newNamespace(name string) *Namespace { | ||
n := &Namespace{ | ||
name: name, | ||
} | ||
namespaces[name] = n | ||
return n | ||
} | ||
|
||
// GetNamespace gets the namespace with the given name. | ||
// If the namespace does not exist yet, a new one is created. | ||
func GetNamespace(name string) *Namespace { | ||
if n, ok := namespaces[name]; ok { | ||
return n | ||
} | ||
return newNamespace(name) | ||
} | ||
|
||
// SetRegistry sets the registry of the namespace | ||
func (n *Namespace) SetRegistry(r *Registry) { | ||
n.registry = r | ||
} | ||
|
||
// GetRegistry gets the registry of the namespace | ||
func (n *Namespace) GetRegistry() *Registry { | ||
if n.registry == nil { | ||
n.registry = NewRegistry() | ||
} | ||
return n.registry | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters