-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathconfig.go
58 lines (46 loc) · 2.51 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package k8sclusterreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver"
import (
"fmt"
"time"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8sclusterreceiver/internal/metadata"
)
// Config defines configuration for kubernetes cluster receiver.
type Config struct {
k8sconfig.APIConfig `mapstructure:",squash"`
// Collection interval for metrics.
CollectionInterval time.Duration `mapstructure:"collection_interval"`
// Node condition types to report. See all condition types, see
// here: https://kubernetes.io/docs/concepts/architecture/nodes/#condition.
NodeConditionTypesToReport []string `mapstructure:"node_conditions_to_report"`
// Allocate resource types to report. See all resource types, see
// here: https://kubernetes.io/docs/concepts/architecture/nodes/#capacity
AllocatableTypesToReport []string `mapstructure:"allocatable_types_to_report"`
// List of exporters to which metadata from this receiver should be forwarded to.
MetadataExporters []string `mapstructure:"metadata_exporters"`
// Whether OpenShift support should be enabled or not.
Distribution string `mapstructure:"distribution"`
// Collection interval for metadata.
// Metadata of the particular entity in the cluster is collected when the entity changes.
// In addition metadata of all entities is collected periodically even if no changes happen.
// Setting the duration to 0 will disable periodic collection (however will not impact
// metadata collection on changes).
MetadataCollectionInterval time.Duration `mapstructure:"metadata_collection_interval"`
// MetricsBuilderConfig allows customizing scraped metrics/attributes representation.
metadata.MetricsBuilderConfig `mapstructure:",squash"`
// Namespace to fetch resources from. If this is set, certain cluster-wide resources such as Nodes or Namespaces
// will not be able to be observed. Setting this option is recommended in environments where due to security restrictions
// the collector can not be granted cluster-wide permissions.
Namespace string `mapstructure:"namespace"`
}
func (cfg *Config) Validate() error {
switch cfg.Distribution {
case distributionOpenShift:
case distributionKubernetes:
default:
return fmt.Errorf("\"%s\" is not a supported distribution. Must be one of: \"openshift\", \"kubernetes\"", cfg.Distribution)
}
return nil
}