Documentation ¶
Overview ¶
Package profiledefinition contain the structure used to parse SNMP Profiles
Index ¶
- Constants
- func IsMetadataResourceWithScalarOids(resource string) bool
- func NormalizeMetrics(metrics []MetricsConfig)
- 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 ProfileDefinition
- type ProfileMetricType
- type StringArray
- type SymbolConfig
Constants ¶
const MetadataDeviceResource = "device"
MetadataDeviceResource is the device resource name
Variables ¶
This section is empty.
Functions ¶
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
Types ¶
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 map[string]MetadataResourceConfig
MetadataConfig holds configs per resource type
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
type MetadataResourceConfig ¶
type MetadataResourceConfig struct { Fields map[string]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
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"` // TODO: refactor to rename to `symbol` instead (keep backward compat with `column`) Column SymbolConfig `yaml:"column,omitempty" json:"column,omitempty"` // Symbol config OID string `yaml:"OID,omitempty" json:"OID,omitempty"` Name string `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
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"` // Legacy Symbol configs syntax OID string `yaml:"OID,omitempty" json:"OID,omitempty" jsonschema:"-"` 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"` ForcedType ProfileMetricType `yaml:"forced_type,omitempty" json:"forced_type,omitempty" jsonschema:"-"` // deprecated in favour of metric_type MetricType ProfileMetricType `yaml:"metric_type,omitempty" json:"metric_type,omitempty"` // `options` is not exposed as json at the moment since we need to evaluate if we want to expose it via UI Options MetricsConfigOption `yaml:"options,omitempty" json:"-"` }
MetricsConfig holds configs for a metric
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) IsScalar ¶
func (m *MetricsConfig) IsScalar() bool
IsScalar returns true if the metrics config define scalar metrics
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 ProfileDefinition ¶
type ProfileDefinition struct { Name string `yaml:"name" json:"name"` 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" jsonschema:"-"` 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"` // Used previously to pass device vendor field (has been replaced by Metadata). // Used in RC for passing device vendor field. Device DeviceMeta `yaml:"device,omitempty" json:"device,omitempty" jsonschema:"device,omitempty"` // DEPRECATED }
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
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/MatchValue are not exposed as json (UI) since ExtractValue can be used instead MatchPattern string `yaml:"match_pattern,omitempty" json:"-"` MatchValue string `yaml:"match_value,omitempty" json:"-"` MatchPatternCompiled *regexp.Regexp `yaml:"-" json:"-"` ScaleFactor float64 `yaml:"scale_factor,omitempty" json:"scale_factor,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
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
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 |