-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
honeycomb: add support for metrics and logs (#38)
This PR adds metrics and logs support when sending data to Honeycomb.
- Loading branch information
Showing
8 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package custom | ||
|
||
import ( | ||
odigosv1 "github.com/keyval-dev/odigos/api/odigos/v1alpha1" | ||
"github.com/keyval-dev/odigos/common" | ||
v1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
func ShouldApplyCustomDataCollection(dests *odigosv1.DestinationList) bool { | ||
for _, dst := range dests.Items { | ||
if destRequiresCustomDataCollection(dst) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func destRequiresCustomDataCollection(dest odigosv1.Destination) bool { | ||
if DestRequiresCustom(dest.Spec.Type) { | ||
for _, s := range dest.Spec.Signals { | ||
if s != common.TracesObservabilitySignal { | ||
return true | ||
} | ||
} | ||
} | ||
|
||
return false | ||
} | ||
|
||
func DestRequiresCustom(destType common.DestinationType) bool { | ||
switch destType { | ||
case common.HoneycombDestinationType: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
func AddCustomConfigMap(dests *odigosv1.DestinationList, cm *corev1.ConfigMap) { | ||
addHoneycombConfig(cm) | ||
} | ||
|
||
func ApplyCustomChangesToDaemonSet(ds *v1.DaemonSet, dests *odigosv1.DestinationList) { | ||
secretName := "" | ||
for _, dst := range dests.Items { | ||
if dst.Spec.Type == common.HoneycombDestinationType { | ||
secretName = dst.Spec.SecretRef.Name | ||
break | ||
} | ||
} | ||
addHoneycombToDaemonSet(ds, secretName) | ||
} |
108 changes: 108 additions & 0 deletions
108
autoscaler/controllers/datacollection/custom/honeycomb.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package custom | ||
|
||
import ( | ||
v1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
const ( | ||
honeycombDataCollectionImage = "honeycombio/honeycomb-kubernetes-agent:2.6.0" | ||
honeycombConfigMountPath = "/etc/honeycomb" | ||
honeycombConfigKey = "honeycomb-conf" | ||
) | ||
|
||
func addHoneycombConfig(cm *corev1.ConfigMap) { | ||
cm.Data[honeycombConfigKey] = ` apiHost: https://api.honeycomb.io/ | ||
watchers: | ||
- dataset: kubernetes-logs | ||
labelSelector: "component=kube-apiserver,tier=control-plane" | ||
namespace: kube-system | ||
parser: glog | ||
- dataset: kubernetes-logs | ||
labelSelector: "component=kube-scheduler,tier=control-plane" | ||
namespace: kube-system | ||
parser: glog | ||
- dataset: kubernetes-logs | ||
labelSelector: "component=kube-controller-manager,tier=control-plane" | ||
namespace: kube-system | ||
parser: glog | ||
- dataset: kubernetes-logs | ||
labelSelector: "k8s-app=kube-proxy" | ||
namespace: kube-system | ||
parser: glog | ||
- dataset: kubernetes-logs | ||
labelSelector: "k8s-app=kube-dns" | ||
namespace: kube-system | ||
parser: glog | ||
verbosity: info | ||
splitLogging: false | ||
metrics: | ||
clusterName: k8s-cluster | ||
dataset: kubernetes-metrics | ||
enabled: true | ||
metricGroups: | ||
- node | ||
- pod` | ||
} | ||
|
||
func addHoneycombToDaemonSet(ds *v1.DaemonSet, secretName string) { | ||
ds.Spec.Template.Spec.Containers = append(ds.Spec.Template.Spec.Containers, corev1.Container{ | ||
Name: "honeycomb-collector", | ||
Image: honeycombDataCollectionImage, | ||
Env: []corev1.EnvVar{ | ||
{ | ||
Name: "NODE_NAME", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
FieldRef: &corev1.ObjectFieldSelector{ | ||
FieldPath: "spec.nodeName", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "NODE_IP", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
FieldRef: &corev1.ObjectFieldSelector{ | ||
FieldPath: "status.hostIP", | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "HONEYCOMB_APIKEY", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
SecretKeyRef: &corev1.SecretKeySelector{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: secretName, | ||
}, | ||
Key: "HONEYCOMB_API_KEY", | ||
}, | ||
}, | ||
}, | ||
}, | ||
VolumeMounts: []corev1.VolumeMount{ | ||
{ | ||
Name: "varlibdockercontainers", | ||
MountPath: "/var/lib/docker/containers", | ||
ReadOnly: true, | ||
}, | ||
{ | ||
Name: "varlog", | ||
MountPath: "/var/log", | ||
ReadOnly: true, | ||
}, | ||
{ | ||
Name: "conf", | ||
MountPath: honeycombConfigMountPath, | ||
ReadOnly: false, | ||
}, | ||
}, | ||
}) | ||
|
||
for i, vol := range ds.Spec.Template.Spec.Volumes { | ||
if vol.Name == "conf" { | ||
ds.Spec.Template.Spec.Volumes[i].VolumeSource.ConfigMap.Items = append(ds.Spec.Template.Spec.Volumes[i].VolumeSource.ConfigMap.Items, corev1.KeyToPath{ | ||
Key: honeycombConfigKey, | ||
Path: "config.yaml", | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters