You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have developed a second development of Cadvisor inside, supported Pod Annotations, and wrote it to the Metrics:
// cadvisor/metrics/prometheus.go
func (c *PrometheusCollector) collectContainersInfo(ch chan<- prometheus.Metric) {
containers, err := c.infoProvider.GetRequestedContainersInfo("/", c.opts)
if err != nil {
c.errors.Set(1)
klog.Warningf("Couldn't get containers: %s", err)
return
}
.....
**********************
c.containerLabelsFunc(container) can be get annotations when use docker as container
**********************
.....
for _, cm := range c.containerMetrics {
if cm.condition != nil && !cm.condition(cont.Spec) {
continue
}
desc := cm.desc(labels)
for _, metricValue := range cm.getValues(stats) {
ch <- prometheus.NewMetricWithTimestamp(
metricValue.timestamp,
prometheus.MustNewConstMetric(desc, cm.valueType, float64(metricValue.value), append(values, metricValue.labels...)...),
)
}
}
}
}
But can't get annotations by c.containerLabelsFunc(container) when use containerd as container in k8s;
The final check found that no Annotation meta was returned in the call:
Calls that get pod meta-information don't get annotations:
// github.com/containerd/containerd/api/services/containers/v1/containers_grpc.pb.go
func (c *containersClient) Get(ctx context.Context, in *GetContainerRequest, opts ...grpc.CallOption) (*GetContainerResponse, error) {
out := new(GetContainerResponse)
err := c.cc.Invoke(ctx, "/containerd.services.containers.v1.Containers/Get", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
This is return object, Annotations are not returned, and no related values exist in the Labels variable:
type Container struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// ID is the user-specified identifier.
//
// This field may not be updated.
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// Labels provides an area to include arbitrary data on containers.
//
// The combined size of a key/value pair cannot exceed 4096 bytes.
//
// Note that to add a new value to this field, read the existing set and
// include the entire result in the update call.
Labels map[string]string `protobuf:"bytes,2,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Image contains the reference of the image used to build the
// specification and snapshots for running this container.
//
// If this field is updated, the spec and rootfs needed to updated, as well.
Image string `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"`
// Runtime specifies which runtime to use for executing this container.
Runtime *Container_Runtime `protobuf:"bytes,4,opt,name=runtime,proto3" json:"runtime,omitempty"`
// Spec to be used when creating the container. This is runtime specific.
Spec *anypb.Any `protobuf:"bytes,5,opt,name=spec,proto3" json:"spec,omitempty"`
// Snapshotter specifies the snapshotter name used for rootfs
Snapshotter string `protobuf:"bytes,6,opt,name=snapshotter,proto3" json:"snapshotter,omitempty"`
// SnapshotKey specifies the snapshot key to use for the container's root
// filesystem. When starting a task from this container, a caller should
// look up the mounts from the snapshot service and include those on the
// task create request.
//
// Snapshots referenced in this field will not be garbage collected.
//
// This field is set to empty when the rootfs is not a snapshot.
//
// This field may be updated.
SnapshotKey string `protobuf:"bytes,7,opt,name=snapshot_key,json=snapshotKey,proto3" json:"snapshot_key,omitempty"`
// CreatedAt is the time the container was first created.
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
// UpdatedAt is the last time the container was mutated.
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
// Extensions allow clients to provide zero or more blobs that are directly
// associated with the container. One may provide protobuf, json, or other
// encoding formats. The primary use of this is to further decorate the
// container object with fields that may be specific to a client integration.
//
// The key portion of this map should identify a "name" for the extension
// that should be unique against other extensions. When updating extension
// data, one should only update the specified extension using field paths
// to select a specific map key.
Extensions map[string]*anypb.Any `protobuf:"bytes,10,rep,name=extensions,proto3" json:"extensions,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
// Sandbox ID this container belongs to.
Sandbox string `protobuf:"bytes,11,opt,name=sandbox,proto3" json:"sandbox,omitempty"`
}
The text was updated successfully, but these errors were encountered:
containerRuntimeVersion: containerd://1.6.31
Support pod anotations as an metrcis labels
We have developed a second development of Cadvisor inside, supported Pod Annotations, and wrote it to the Metrics:
// cadvisor/metrics/prometheus.go
But can't get annotations by
c.containerLabelsFunc(container)
when use containerd as container in k8s;The final check found that no Annotation meta was returned in the call:
Calls that get pod meta-information don't get annotations:
// github.com/containerd/containerd/api/services/containers/v1/containers_grpc.pb.go
This is return object,
Annotations
are not returned, and no related values exist in the Labels variable:The text was updated successfully, but these errors were encountered: