Documentation
¶
Overview ¶
Copyright 2020, OpenTelemetry Authors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. nolint:gocritic
Copyright 2020, OpenTelemetry Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. nolint:gocritic
Copyright 2020, OpenTelemetry Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. nolint:gocritic
Copyright 2020, OpenTelemetry Authors ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func ConvertToOTLPMetrics(fields map[string]interface{}, tags map[string]string, logger *zap.Logger) pmetric.Metrics
- func GetUnitForMetric(metric string) string
- func IsContainer(mType string) bool
- func IsInstance(mType string) bool
- func IsNode(mType string) bool
- func IsPod(mType string) bool
- func MetricName(mType string, measurement string) string
- func RemovePrefix(mType string, metricName string) string
- func SumFields(fields []map[string]interface{}) map[string]float64
Constants ¶
const ( GoPSUtilProcDirEnv = "HOST_PROC" //We assume 50 micro-seconds is the minimal gap between two collected data sample to be valid to calculate delta MinTimeDiff = 50 * time.Microsecond //Attribute names InstanceID = "InstanceId" InstanceType = "InstanceType" ClusterNameKey = "ClusterName" AutoScalingGroupNameKey = "AutoScalingGroupName" NodeNameKey = "NodeName" Version = "Version" DiskDev = "device" EbsVolumeID = "ebs_volume_id" //used by kubernetes cluster as persistent volume HostEbsVolumeID = "EBSVolumeId" //used by host filesystem FSType = "fstype" MetricType = "Type" SourcesKey = "Sources" Timestamp = "Timestamp" //The following constants are used for metric name construction CPUTotal = "cpu_usage_total" CPUUser = "cpu_usage_user" CPUSystem = "cpu_usage_system" CPULimit = "cpu_limit" CPUUtilization = "cpu_utilization" CPURequest = "cpu_request" CPUReservedCapacity = "cpu_reserved_capacity" CPUUtilizationOverPodLimit = "cpu_utilization_over_pod_limit" MemUsage = "memory_usage" MemCache = "memory_cache" MemRss = "memory_rss" MemMaxusage = "memory_max_usage" MemSwap = "memory_swap" MemFailcnt = "memory_failcnt" MemMappedfile = "memory_mapped_file" MemWorkingset = "memory_working_set" MemPgfault = "memory_pgfault" MemPgmajfault = "memory_pgmajfault" MemHierarchicalPgfault = "memory_hierarchical_pgfault" MemHierarchicalPgmajfault = "memory_hierarchical_pgmajfault" MemLimit = "memory_limit" MemRequest = "memory_request" MemUtilization = "memory_utilization" MemReservedCapacity = "memory_reserved_capacity" MemUtilizationOverPodLimit = "memory_utilization_over_pod_limit" NetIfce = "interface" NetRxBytes = "network_rx_bytes" NetRxPackets = "network_rx_packets" NetRxDropped = "network_rx_dropped" NetRxErrors = "network_rx_errors" NetTxBytes = "network_tx_bytes" NetTxPackets = "network_tx_packets" NetTxDropped = "network_tx_dropped" NetTxErrors = "network_tx_errors" NetTotalBytes = "network_total_bytes" FSUsage = "filesystem_usage" FSCapacity = "filesystem_capacity" FSAvailable = "filesystem_available" FSInodes = "filesystem_inodes" FSInodesfree = "filesystem_inodes_free" FSUtilization = "filesystem_utilization" RunningPodCount = "number_of_running_pods" RunningContainerCount = "number_of_running_containers" ContainerCount = "number_of_containers" NodeCount = "node_count" FailedNodeCount = "failed_node_count" ContainerRestartCount = "number_of_container_restarts" RunningTaskCount = "number_of_running_tasks" DiskIOServiceBytesPrefix = "diskio_io_service_bytes_" DiskIOServicedPrefix = "diskio_io_serviced_" DiskIOAsync = "Async" DiskIORead = "Read" DiskIOSync = "Sync" DiskIOWrite = "Write" DiskIOTotal = "Total" //Define the metric types TypeCluster = "Cluster" TypeClusterService = "ClusterService" TypeClusterNamespace = "ClusterNamespace" TypeService = "Service" TypeInstance = "Instance" //mean EC2 Instance in ECS TypeNode = "Node" //mean EC2 Instance in EKS TypeInstanceFS = "InstanceFS" TypeNodeFS = "NodeFS" TypeInstanceNet = "InstanceNet" TypeNodeNet = "NodeNet" TypeInstanceDiskIO = "InstanceDiskIO" TypeNodeDiskIO = "NodeDiskIO" TypePod = "Pod" TypePodNet = "PodNet" TypeContainer = "Container" TypeContainerFS = "ContainerFS" TypeContainerDiskIO = "ContainerDiskIO" //unit UnitBytes = "Bytes" UnitMegaBytes = "Megabytes" UnitNanoSecond = "Nanoseconds" UnitBytesPerSec = "Bytes/Second" UnitCount = "Count" UnitCountPerSec = "Count/Second" UnitVCPU = "vCPU" UnitPercent = "Percent" )
define metric names, attribute names, metric types, and units for both EKS and ECS Container Insights
const ( ContainerInstanceIDKey = "ContainerInstanceId" ECS = "ecs" )
define constants that are used for ECS Container Insights only
const ( EKS = "eks" KubeSecurePort = "10250" BearerToken = "/var/run/secrets/kubernetes.io/serviceaccount/token" // #nosec to suppress lint error G101: Potential hardcoded credentials CAFile = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt" //attribute names Kubernetes = "kubernetes" K8sNamespace = "Namespace" PodIDKey = "PodId" PodNameKey = "PodName" FullPodNameKey = "FullPodName" K8sPodNameKey = "K8sPodName" ContainerNamekey = "ContainerName" ContainerIDkey = "ContainerId" PodOwnersKey = "PodOwners" PodStatus = "pod_status" ContainerStatus = "container_status" ContainerStatusReason = "container_status_reason" ContainerLastTerminationReason = "container_last_termination_reason" //Pod Owners ReplicaSet = "ReplicaSet" ReplicationController = "ReplicationController" StatefulSet = "StatefulSet" DaemonSet = "DaemonSet" Deployment = "Deployment" Job = "Job" CronJob = "CronJob" )
define constants that are used for EKS Container Insights only
Variables ¶
This section is empty.
Functions ¶
func ConvertToOTLPMetrics ¶
func ConvertToOTLPMetrics(fields map[string]interface{}, tags map[string]string, logger *zap.Logger) pmetric.Metrics
ConvertToOTLPMetrics converts a field containing metric values and a tag containing the relevant labels to OTLP metrics
func GetUnitForMetric ¶
GetUnitForMetric returns unit for a given metric
func IsContainer ¶
IsContainer checks if a type belongs to container level metrics
func IsInstance ¶
IsInstance checks if a type belongs to instance level metrics (for ECS)
func MetricName ¶
MetricName returns the metric name based on metric type and measurement name For example, a type "node" and a measurement "cpu_utilization" gives "node_cpu_utilization"
func RemovePrefix ¶
RemovePrefix removes the prefix (e.g. "node_", "pod_") from the metric name
Types ¶
This section is empty.