Skip to content

Commit

Permalink
add a few more pod tags (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed Mar 24, 2017
1 parent c017f1d commit e24eb50
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
9 changes: 9 additions & 0 deletions README.adoc
Expand Up @@ -887,6 +887,15 @@ Tag values can be defined with token expressions in the form of `${var}` or `$va
|POD:label[_key_]
|A single Pod label value for the label key _key_

|POD:cluster_name
|The name of the cluster that the pod is a member of.

|POD:resource_version
|The resource version of the Pod resource.

|POD:self_link
|The link to the Pod resource itself.

|METRIC:name
|The name of the metric on which this tag is found.

Expand Down
2 changes: 2 additions & 0 deletions deploy/openshift/hawkular-openshift-agent-configmap.yaml
Expand Up @@ -38,6 +38,8 @@ data:
hostname: ${POD:hostname}
host_ip: ${POD:host_ip}
labels: ${POD:labels}
cluster_name: ${POD:cluster_name}
resource_version: ${POD:resource_version}
type: pod
collector: hawkular_openshift_agent
custom_metric: true
Expand Down
3 changes: 3 additions & 0 deletions k8s/discovery.go
Expand Up @@ -256,6 +256,9 @@ func (d *Discovery) watchPods() {
Labels: podFromEvent.GetLabels(),
Annotations: podFromEvent.GetAnnotations(),
ConfigMapVolumes: cmVols,
ClusterName: podFromEvent.GetClusterName(),
ResourceVersion: podFromEvent.GetResourceVersion(),
SelfLink: podFromEvent.GetSelfLink(),
}

switch event.Type {
Expand Down
25 changes: 14 additions & 11 deletions k8s/node_event_consumer.go
Expand Up @@ -208,17 +208,20 @@ func (nec *NodeEventConsumer) startCollecting(ne *NodeEvent) {
// Define additional envvars with pod specific data for use in replacing ${env} tokens.
// These tokens are used in tags and in the Tenant field.
additionalEnv := map[string]string{
"POD:node_name": ne.Pod.Node.Name,
"POD:node_uid": ne.Pod.Node.UID,
"POD:namespace_name": ne.Pod.Namespace.Name,
"POD:namespace_uid": ne.Pod.Namespace.UID,
"POD:name": ne.Pod.Name,
"POD:ip": ne.Pod.PodIP,
"POD:host_ip": ne.Pod.HostIP,
"POD:uid": ne.Pod.UID,
"POD:hostname": ne.Pod.Hostname,
"POD:subdomain": ne.Pod.Subdomain,
"POD:labels": joinMap(ne.Pod.Labels),
"POD:node_name": ne.Pod.Node.Name,
"POD:node_uid": ne.Pod.Node.UID,
"POD:namespace_name": ne.Pod.Namespace.Name,
"POD:namespace_uid": ne.Pod.Namespace.UID,
"POD:name": ne.Pod.Name,
"POD:ip": ne.Pod.PodIP,
"POD:host_ip": ne.Pod.HostIP,
"POD:uid": ne.Pod.UID,
"POD:hostname": ne.Pod.Hostname,
"POD:subdomain": ne.Pod.Subdomain,
"POD:labels": joinMap(ne.Pod.Labels),
"POD:cluster_name": ne.Pod.ClusterName,
"POD:resource_version": ne.Pod.ResourceVersion,
"POD:self_link": ne.Pod.SelfLink,
}

// support ${POD:label[<label-name>]}
Expand Down
3 changes: 3 additions & 0 deletions k8s/pod.go
Expand Up @@ -33,6 +33,9 @@ type Pod struct {
Labels map[string]string
Annotations map[string]string
ConfigMapVolumes map[string]string
ClusterName string
ResourceVersion string
SelfLink string
}

// Identifier returns a string smaller than String() but can still uniquely identify the pod
Expand Down

0 comments on commit e24eb50

Please sign in to comment.