Documentation
¶
Overview ¶
Package profiledefinition contain the structure used to parse SNMP Profiles
Index ¶
- Constants
- Variables
- func CloneMap[Map ~map[K]T, K comparable, T Cloneable[T]](m Map) Map
- func CloneSlice[Slice ~[]T, T Cloneable[T]](s Slice) Slice
- func IsLegacyMetrics(metrics []MetricsConfig) bool
- func IsMetadataResourceWithScalarOids(resource string) bool
- func NormalizeMetrics(metrics []MetricsConfig)
- func ValidateEnrichMetadata(metadata MetadataConfig) []string
- func ValidateEnrichMetricTags(metricTags []MetricTagConfig) []string
- func ValidateEnrichMetrics(metrics []MetricsConfig) []string
- func ValidateEnrichProfile(profile *ProfileDefinition) []string
- type Cloneable
- type DeviceMeta
- type DeviceProfileRcConfig
- type ListMap
- type MapItem
- type MetadataConfig
- type MetadataField
- type MetadataResourceConfig
- type MetricIndexTransform
- type MetricTagConfig
- type MetricTagConfigList
- type MetricsConfig
- type MetricsConfigOption
- type ProfileBundle
- type ProfileBundleProfileItem
- type ProfileDefinition
- type ProfileMetricType
- type StringArray
- type SymbolConfig
- type SymbolConfigCompat
- type SymbolContext
Constants ¶
const MetadataDeviceResource = "device"
MetadataDeviceResource is the device resource name
Variables ¶
var ErrLegacySymbolType = errors.New("legacy symbol type 'string' is not supported with the Core loader")
ErrLegacySymbolType is returned when unmarshaling a MetricsConfig with a legacy string symbol type
Functions ¶
func CloneMap ¶ added in v0.64.0
func CloneMap[Map ~map[K]T, K comparable, T Cloneable[T]](m Map) Map
CloneMap clones a map[K]T for any cloneable type T. The map keys are shallow-copied; values are cloned.
func CloneSlice ¶ added in v0.64.0
func CloneSlice[Slice ~[]T, T Cloneable[T]](s Slice) Slice
CloneSlice clones all the objects in a slice into a new slice.
func IsLegacyMetrics ¶ added in v0.67.0
func IsLegacyMetrics(metrics []MetricsConfig) bool
IsLegacyMetrics returns true if one or more metrics config is written in the legacy Python syntax
func IsMetadataResourceWithScalarOids ¶
IsMetadataResourceWithScalarOids returns true if the resource is based on scalar OIDs at the moment, we only expect "device" resource to be based on scalar OIDs
func NormalizeMetrics ¶
func NormalizeMetrics(metrics []MetricsConfig)
NormalizeMetrics converts legacy syntax to new syntax 1/ converts old symbol syntax to new symbol syntax metric.Name and metric.OID info are moved to metric.Symbol.Name and metric.Symbol.OID
func ValidateEnrichMetadata ¶ added in v0.64.0
func ValidateEnrichMetadata(metadata MetadataConfig) []string
ValidateEnrichMetadata will validate MetadataConfig and enrich it.
func ValidateEnrichMetricTags ¶ added in v0.64.0
func ValidateEnrichMetricTags(metricTags []MetricTagConfig) []string
ValidateEnrichMetricTags validates and normalizes metric tags
func ValidateEnrichMetrics ¶ added in v0.64.0
func ValidateEnrichMetrics(metrics []MetricsConfig) []string
ValidateEnrichMetrics will validate MetricsConfig and enrich it. Example of enrichment: - storage of compiled regex pattern
func ValidateEnrichProfile ¶ added in v0.64.0
func ValidateEnrichProfile(profile *ProfileDefinition) []string
ValidateEnrichProfile validates a profile and normalizes it.
Types ¶
type Cloneable ¶ added in v0.64.0
type Cloneable[T any] interface { Clone() T }
Cloneable is a generic type for objects that can duplicate themselves. It is exclusively used in the form [T Cloneable[T]], i.e. a type that has a .Clone() that returns a new instance of itself.
type DeviceMeta ¶
type DeviceMeta struct {
// deprecated in favour of new `ProfileDefinition.Metadata` syntax
Vendor string `yaml:"vendor,omitempty" json:"vendor,omitempty"`
}
DeviceMeta holds device related static metadata DEPRECATED in favour of profile metadata syntax
type DeviceProfileRcConfig ¶
type DeviceProfileRcConfig struct {
Profile ProfileDefinition `json:"profile_definition"`
}
DeviceProfileRcConfig represent the profile stored in remote config.
type ListMap ¶
ListMap is used to marshall a map into a list (map[string]T to []MapItem[T]) and vice versa.
func (ListMap[T]) JSONSchema ¶
func (lm ListMap[T]) JSONSchema() *jsonschema.Schema
JSONSchema is needed to customize jsonschema to match []MapItem[T] used in json format
func (ListMap[T]) MarshalJSON ¶
MarshalJSON marshalls map to list
func (*ListMap[T]) UnmarshalJSON ¶
UnmarshalJSON unmarshalls list to map
type MetadataConfig ¶
type MetadataConfig ListMap[MetadataResourceConfig]
MetadataConfig holds configs per resource type
func (MetadataConfig) Clone ¶ added in v0.64.0
func (mc MetadataConfig) Clone() MetadataConfig
Clone duplicates this MetadataConfig
func (MetadataConfig) JSONSchema ¶ added in v0.63.0
func (mc MetadataConfig) JSONSchema() *jsonschema.Schema
JSONSchema defines the JSON schema for MetadataConfig
func (MetadataConfig) MarshalJSON ¶ added in v0.63.0
func (mc MetadataConfig) MarshalJSON() ([]byte, error)
MarshalJSON marshals the metadata config
func (*MetadataConfig) UnmarshalJSON ¶ added in v0.63.0
func (mc *MetadataConfig) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals the metadata config
type MetadataField ¶
type MetadataField struct {
Symbol SymbolConfig `yaml:"symbol,omitempty" json:"symbol,omitempty"`
Symbols []SymbolConfig `yaml:"symbols,omitempty" json:"symbols,omitempty"`
Value string `yaml:"value,omitempty" json:"value,omitempty"`
}
MetadataField holds configs for a metadata field
func (MetadataField) Clone ¶ added in v0.64.0
func (f MetadataField) Clone() MetadataField
Clone duplicates this MetadataField
func (*MetadataField) IsEmpty ¶ added in v0.73.0
func (f *MetadataField) IsEmpty() bool
IsEmpty is true if this is nil or the zero value.
type MetadataResourceConfig ¶
type MetadataResourceConfig struct {
Fields ListMap[MetadataField] `yaml:"fields" json:"fields"`
IDTags MetricTagConfigList `yaml:"id_tags,omitempty" json:"id_tags,omitempty"`
}
MetadataResourceConfig holds configs for a metadata resource
func NewMetadataResourceConfig ¶
func NewMetadataResourceConfig() MetadataResourceConfig
NewMetadataResourceConfig returns a new metadata resource config
func (MetadataResourceConfig) Clone ¶ added in v0.64.0
func (c MetadataResourceConfig) Clone() MetadataResourceConfig
Clone duplicates this MetadataResourceConfig
type MetricIndexTransform ¶
type MetricIndexTransform struct {
Start uint `yaml:"start" json:"start"`
End uint `yaml:"end" json:"end"`
}
MetricIndexTransform holds configs for metric index transform
type MetricTagConfig ¶
type MetricTagConfig struct {
Tag string `yaml:"tag" json:"tag"`
// Table config
Index uint `yaml:"index,omitempty" json:"index,omitempty"`
// DEPRECATED: Use .Symbol instead
Column SymbolConfig `yaml:"column,omitempty" json:"-"`
// DEPRECATED: use .Symbol instead
OID string `yaml:"OID,omitempty" json:"-" jsonschema:"-"`
// Symbol records the OID to be parsed. Note that .Symbol.Name is ignored:
// set .Tag to specify the tag name. If a serialized Symbol is a string
// instead of an object, it will be treated like {name: <value>}; this use
// pattern is deprecated
Symbol SymbolConfigCompat `yaml:"symbol,omitempty" json:"symbol,omitempty"`
IndexTransform []MetricIndexTransform `yaml:"index_transform,omitempty" json:"index_transform,omitempty"`
Mapping ListMap[string] `yaml:"mapping,omitempty" json:"mapping,omitempty"`
// Regex
// Match/Tags are not exposed as json (UI) since ExtractValue can be used instead
Match string `yaml:"match,omitempty" json:"-"`
Tags map[string]string `yaml:"tags,omitempty" json:"-"`
Pattern *regexp.Regexp `yaml:"-" json:"-"`
SymbolTag string `yaml:"-" json:"-"`
}
MetricTagConfig holds metric tag info
func (MetricTagConfig) Clone ¶ added in v0.64.0
func (m MetricTagConfig) Clone() MetricTagConfig
Clone duplicates this MetricTagConfig
type MetricTagConfigList ¶
type MetricTagConfigList []MetricTagConfig
MetricTagConfigList holds configs for a list of metric tags
func (*MetricTagConfigList) UnmarshalYAML ¶
func (mtcl *MetricTagConfigList) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshalls MetricTagConfigList
type MetricsConfig ¶
type MetricsConfig struct {
// MIB the MIB used for this metric
MIB string `yaml:"MIB,omitempty" json:"MIB,omitempty"`
// Table the table OID
Table SymbolConfig `yaml:"table,omitempty" json:"table,omitempty"`
// Symbol configs
Symbol SymbolConfig `yaml:"symbol,omitempty" json:"symbol,omitempty"`
// DEPRECATED: Use .Symbol instead
OID string `yaml:"OID,omitempty" json:"OID,omitempty" jsonschema:"-"`
// DEPRECATED: Use .Symbol instead
Name string `yaml:"name,omitempty" json:"name,omitempty" jsonschema:"-"`
// Table configs
Symbols []SymbolConfig `yaml:"symbols,omitempty" json:"symbols,omitempty"`
// `static_tags` is not exposed as json at the moment since we need to evaluate if we want to expose it via UI
StaticTags []string `yaml:"static_tags,omitempty" json:"-"`
MetricTags MetricTagConfigList `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"`
// DEPRECATED: use Symbol.MetricType instead.
ForcedType ProfileMetricType `yaml:"forced_type,omitempty" json:"forced_type,omitempty" jsonschema:"-"`
// DEPRECATED: use Symbol.MetricType instead.
MetricType ProfileMetricType `yaml:"metric_type,omitempty" json:"metric_type,omitempty" jsonschema:"-"`
Options MetricsConfigOption `yaml:"options,omitempty" json:"options,omitempty"`
}
MetricsConfig holds configs for a metric
func (MetricsConfig) Clone ¶ added in v0.64.0
func (m MetricsConfig) Clone() MetricsConfig
Clone duplicates this MetricsConfig
func (*MetricsConfig) GetSymbolTags ¶
func (m *MetricsConfig) GetSymbolTags() []string
GetSymbolTags returns symbol tags
func (*MetricsConfig) IsColumn ¶
func (m *MetricsConfig) IsColumn() bool
IsColumn returns true if the metrics config define columns metrics
func (*MetricsConfig) IsLegacy ¶ added in v0.67.0
func (m *MetricsConfig) IsLegacy() bool
IsLegacy returns true if the metrics config is written in the legacy Python syntax
func (*MetricsConfig) IsScalar ¶
func (m *MetricsConfig) IsScalar() bool
IsScalar returns true if the metrics config define scalar metrics
func (*MetricsConfig) UnmarshalYAML ¶ added in v0.67.0
func (mc *MetricsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshalls MetricsConfig
type MetricsConfigOption ¶
type MetricsConfigOption struct {
Placement uint `yaml:"placement,omitempty" json:"placement,omitempty"`
MetricSuffix string `yaml:"metric_suffix,omitempty" json:"metric_suffix,omitempty"`
}
MetricsConfigOption holds config for metrics options
type ProfileBundle ¶ added in v0.50.0
type ProfileBundle struct {
CreatedTimestamp int64 `json:"created_timestamp"` // Millisecond
Profiles []ProfileBundleProfileItem `json:"profiles"`
}
ProfileBundle represent a list of profiles meant to be downloaded by user.
type ProfileBundleProfileItem ¶ added in v0.50.0
type ProfileBundleProfileItem struct {
Profile ProfileDefinition `json:"profile"`
}
ProfileBundleProfileItem represent a profile entry with metadata.
type ProfileDefinition ¶
type ProfileDefinition struct {
Name string `yaml:"name,omitempty" json:"name,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
SysObjectIDs StringArray `yaml:"sysobjectid,omitempty" json:"sysobjectid,omitempty"`
Extends []string `yaml:"extends,omitempty" json:"extends,omitempty"`
Metadata MetadataConfig `yaml:"metadata,omitempty" json:"metadata,omitempty"`
MetricTags []MetricTagConfig `yaml:"metric_tags,omitempty" json:"metric_tags,omitempty"`
StaticTags []string `yaml:"static_tags,omitempty" json:"static_tags,omitempty"`
Metrics []MetricsConfig `yaml:"metrics,omitempty" json:"metrics,omitempty"`
// DEPRECATED: Use metadata directly
Device DeviceMeta `yaml:"device,omitempty" json:"device,omitempty" jsonschema:"device,omitempty"`
// Version is the profile version.
// It is currently used only with downloaded/RC profiles.
Version uint64 `yaml:"version,omitempty" json:"version,omitempty"`
}
ProfileDefinition is the root profile structure. The ProfileDefinition is currently used in: 1/ SNMP Integration: the profiles are in yaml profiles. Yaml profiles include default datadog profiles and user custom profiles. The serialisation of yaml profiles are defined by the yaml annotation and few custom unmarshaller (see yaml_utils.go). 2/ Datadog backend: the profiles are in json format, they are used to store profiles created via UI. The serialisation of json profiles are defined by the json annotation.
func NewProfileDefinition ¶
func NewProfileDefinition() *ProfileDefinition
NewProfileDefinition creates a new ProfileDefinition
func (*ProfileDefinition) Clone ¶ added in v0.64.0
func (p *ProfileDefinition) Clone() *ProfileDefinition
Clone duplicates this ProfileDefinition
type ProfileMetricType ¶
type ProfileMetricType string
ProfileMetricType metric type used to override default type of the metric By default metric type is derived from the type of the SNMP value, for example Counter32/64 -> rate.
const ( // ProfileMetricTypeGauge is used to create a gauge metric ProfileMetricTypeGauge ProfileMetricType = "gauge" // ProfileMetricTypeMonotonicCount is used to create a monotonic_count metric ProfileMetricTypeMonotonicCount ProfileMetricType = "monotonic_count" // ProfileMetricTypeMonotonicCountAndRate is used to create a monotonic_count and rate metric ProfileMetricTypeMonotonicCountAndRate ProfileMetricType = "monotonic_count_and_rate" // ProfileMetricTypeRate is used to create a rate metric ProfileMetricTypeRate ProfileMetricType = "rate" // ProfileMetricTypeFlagStream is used to create metric based on a value that represent flags // See details in https://github.com/DataDog/integrations-core/pull/7072 ProfileMetricTypeFlagStream ProfileMetricType = "flag_stream" // ProfileMetricTypeCounter is DEPRECATED // `counter` is deprecated in favour of `rate` ProfileMetricTypeCounter ProfileMetricType = "counter" // ProfileMetricTypePercent is DEPRECATED // `percent` is deprecated in favour of `scale_factor` ProfileMetricTypePercent ProfileMetricType = "percent" )
type StringArray ¶
type StringArray []string
StringArray is list of string with a yaml un-marshaller that support both array and string. See test file for example usage. Credit: https://github.com/go-yaml/yaml/issues/100#issuecomment-324964723
func (*StringArray) UnmarshalYAML ¶
func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshalls StringArray
type SymbolConfig ¶
type SymbolConfig struct {
OID string `yaml:"OID,omitempty" json:"OID,omitempty"`
Name string `yaml:"name,omitempty" json:"name,omitempty"`
ExtractValue string `yaml:"extract_value,omitempty" json:"extract_value,omitempty"`
ExtractValueCompiled *regexp.Regexp `yaml:"-" json:"-"`
MatchPattern string `yaml:"match_pattern,omitempty" json:"match_pattern,omitempty"`
MatchValue string `yaml:"match_value,omitempty" json:"match_value,omitempty"`
MatchPatternCompiled *regexp.Regexp `yaml:"-" json:"-"`
ScaleFactor float64 `yaml:"scale_factor,omitempty" json:"scale_factor,omitempty"`
// RC doesn't support float64 values, so we use string for rc profiles.
ScaleFactorString string `yaml:"-" json:"scale_factor_string,omitempty"`
Format string `yaml:"format,omitempty" json:"format,omitempty"`
ConstantValueOne bool `yaml:"constant_value_one,omitempty" json:"constant_value_one,omitempty"`
// `metric_type` is used for force the metric type
// When empty, by default, the metric type is derived from SNMP OID value type.
// Valid `metric_type` types: `gauge`, `rate`, `monotonic_count`, `monotonic_count_and_rate`
// Deprecated types: `counter` (use `rate` instead), percent (use `scale_factor` instead)
MetricType ProfileMetricType `yaml:"metric_type,omitempty" json:"metric_type,omitempty"`
}
SymbolConfig holds info for a single symbol/oid
func (SymbolConfig) Clone ¶ added in v0.64.0
func (s SymbolConfig) Clone() SymbolConfig
Clone creates a duplicate of this SymbolConfig
type SymbolConfigCompat ¶ added in v0.50.0
type SymbolConfigCompat SymbolConfig
SymbolConfigCompat is used to deserialize string field or SymbolConfig. For OID/Name to Symbol harmonization: When users declare metric tag like:
metric_tags:
- OID: 1.2.3
symbol: aSymbol
this will lead to OID stored as MetricTagConfig.OID and name stored as MetricTagConfig.Symbol.Name When this happens, in ValidateEnrichMetricTags we harmonize by moving MetricTagConfig.OID to MetricTagConfig.Symbol.OID.
func (SymbolConfigCompat) Clone ¶ added in v0.64.0
func (s SymbolConfigCompat) Clone() SymbolConfigCompat
Clone creates a duplicate of this SymbolConfigCompat
func (*SymbolConfigCompat) UnmarshalYAML ¶ added in v0.50.0
func (a *SymbolConfigCompat) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML unmarshalls SymbolConfig
type SymbolContext ¶ added in v0.64.0
type SymbolContext int64
SymbolContext represent the context in which the symbol is used
const ( ScalarSymbol SymbolContext = iota ColumnSymbol MetricTagSymbol MetadataSymbol )
ScalarSymbol enums
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. |
|
cmd
Package cmd implements a cobra command for validating and normalizing profiles.
|
Package cmd implements a cobra command for validating and normalizing profiles. |
|
Package schema contain json schema related code
|
Package schema contain json schema related code |
|
Package main holds main related files
|
Package main holds main related files |