Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
gantrior authored Oct 9, 2023
2 parents 9d9a8bb + 3616f74 commit 3b67305
Show file tree
Hide file tree
Showing 29 changed files with 798 additions and 984 deletions.
17 changes: 12 additions & 5 deletions .github/actions/run-integration-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ runs:
kubectl create job --from=cronjob/integration-test integration-test-manual
kubectl wait --for=condition=ready --timeout=60s pod -l job-name=integration-test-manual
kubetail -l job-name=integration-test-manual &
kubetail -l job-name=integration-test-manual &
# Wait for either complete or failed -
while true; do
Expand All @@ -28,14 +28,14 @@ runs:
if [[ $job_result -eq 1 ]]; then
echo "Tests failed"
mkdir pod-logs
echo "Folder Created"
pods=$(kubectl get pods -n monitoring -o=jsonpath='{.items[*].metadata.name}')
for pod in $pods; do
containers=$(kubectl get pod $pod -n monitoring -o=jsonpath='{.spec.containers[*].name}')
for container in $containers; do
echo "Logs for pod $pod, container $container:"
kubectl logs -n monitoring $pod -c $container
echo -e "\n\n"
echo "Logs for pod $pod, container $container:"
kubectl logs -n monitoring $pod -c $container > pod-logs/$container.txt
done
done
Expand All @@ -44,6 +44,13 @@ runs:
echo "Tests succeeded"
shell: bash
- name: Upload pod logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: pod-logs
path: pod-logs/
retention-days: 1



Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/buildAndDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -305,21 +305,21 @@ jobs:

- name: Get image tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
run: echo "tag=$env:GITHUB_REF_NAME" >> $ENV:GITHUB_OUTPUT

- name: Load image
run: |
docker load --input swi-k8s-opentelemetry-collector-windows.tar
- name: Tag images
run: |
docker tag swi-k8s-opentelemetry-collector:${{ needs.build_and_test.outputs.image_tag }}-nanoserver-ltsc2022 ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2022
docker tag swi-k8s-opentelemetry-collector:${{ needs.build_and_test_windows.outputs.image_tag }}-nanoserver-ltsc2022 ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2022
- name: Docker login
env:
DOCKER_HUB_CI_PASSWORD: ${{ secrets.DOCKER_HUB_CI_PASSWORD }}
DOCKER_HUB_CI_USER: ${{ secrets.DOCKER_HUB_CI_USER }}
run: echo "$DOCKER_HUB_CI_PASSWORD" | docker login -u "$DOCKER_HUB_CI_USER" --password-stdin
run: echo "$env:DOCKER_HUB_CI_PASSWORD" | docker login -u "$env:DOCKER_HUB_CI_USER" --password-stdin

- name: Push as specific
run: docker push ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2022
Expand Down
17 changes: 10 additions & 7 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ FROM debian:11.7@sha256:432f545c6ba13b79e2681f4cc4858788b0ab099fc1cca799cc0fae46
RUN apt update
RUN apt install -y systemd

FROM scratch

ARG USER_UID=10001
USER ${USER_UID}

COPY --from=prep /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /src/swi-k8s-opentelemetry-collector /swi-otelcol
FROM scratch as journalbinaries

# dynamically linked libraries that are required for journalctl and the journalctl binary itself
# use `ldd /bin/journalctl` to get dynamically linked libraries from the binary
Expand Down Expand Up @@ -60,6 +54,15 @@ COPY --from=journal /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 /usr/lib/x86_64-li
COPY --from=journal /lib/x86_64-linux-gnu/libcap-ng.so.0 /lib/x86_64-linux-gnu/libcap-ng.so.0
COPY --from=journal /bin/journalctl /bin/journalctl

FROM scratch

ARG USER_UID=10001
USER ${USER_UID}

COPY --from=prep /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /src/swi-k8s-opentelemetry-collector /swi-otelcol
COPY --from=journalbinaries / /

ENTRYPOINT ["/swi-otelcol"]
CMD ["--config=/opt/default-config.yaml"]

2 changes: 1 addition & 1 deletion build/docker/structure-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ commandTests:
- name: "swi-otelcol is working in the image"
command: "/swi-otelcol"
args: ["-v"]
expectedOutput: ["swi-k8s-opentelemetry-collector version 0.8.2"]
expectedOutput: ["swi-k8s-opentelemetry-collector version 0.8.4"]
13 changes: 0 additions & 13 deletions build/docker/wiremockFiles/redirectKubeStateMetricsResponse.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ kube_pod_container_resource_limits{container="test-container",endpoint="http",in
kube_pod_container_resource_limits{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",resource="memory",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",unit="byte",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 3.221225472e+09 1675856675021
kube_pod_container_resource_limits{container="test-container",endpoint="tcp-model",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",resource="memory",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",unit="byte",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 3.221225472e+09 1675856675021
kube_pod_container_resource_limits{container="test-container",endpoint="tcp-model",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",resource="cpu",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",unit="core",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 0.1 1675856675021
# TYPE kube_pod_container_resource_limits_cpu_cores untyped
kube_pod_container_resource_limits_cpu_cores{container="test-container",endpoint="tcp-model",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",service="test-service",uid="71057e83-7723-4db5-a7ca-52ad7904e34d",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1 1675856675021
# TYPE kube_pod_container_resource_limits_memory_bytes untyped
kube_pod_container_resource_limits_memory_bytes{container="test-container",endpoint="tcp-model",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",service="test-service",uid="03d2b55c-b225-476b-9178-c74f8e5eaba2",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 2.68435456e+08 1675856675021
kube_pod_container_resource_limits_memory_bytes{container="test-container",endpoint="tcp-model",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 3.221225472e+09 1675856675021
# TYPE kube_pod_container_resource_requests untyped
kube_pod_container_resource_requests{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",resource="cpu",service="test-service",uid="f15ca7ca-af33-4f43-a793-ec3176b31842",unit="core",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 0.1 1675856675021
kube_pod_container_resource_requests{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",node="test-node",pod="test-pod",resource="memory",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",unit="byte",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 3.221225472e+09 1675856675021
Expand Down Expand Up @@ -242,14 +237,6 @@ kube_pod_info{container="test-container",created_by_kind="ReplicaSet",created_by
kube_pod_init_container_info{container="test-container",container_id="docker://f1c98663d614379552d6c9aae831b4eb3e149c469d4d589b62ea077cf3dad807",endpoint="http",image="busybox:1.29.2",image_id="docker-pullable://busybox@sha256:cb63aa0641a885f54de20f61d152187419e8f6b159ed11a251a09d115fdff9bd",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="9cab81cb-9da1-4029-ac51-c7c3024c6fbf",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1 1675856675021
kube_pod_init_container_info{container="test-container",container_id="docker://f55a97f615b1a90f15f114def871a7d4f0ed8a32d9a329cc7e2f94a24d4780c1",endpoint="http",image="fullstorydev/grpcurl:latest",image_id="docker-pullable://fullstorydev/grpcurl@sha256:d42ef512419560776bee5bb51e338a1734a0edb99f450b6d98fd98bcc93796f3",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1 1675856675021
kube_pod_init_container_info{container="test-container",container_id="docker://6fb07210b86971939dbfb16ae47f98afdb8214a52a21dd5fc26f21ae35c09d9e",endpoint="http",image="busybox:latest",image_id="docker-pullable://busybox@sha256:b5d6fe0712636ceb7430189de28819e195e8966372edfc2d9409d79402a0dc16",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1 1675856675021
# TYPE kube_pod_init_container_resource_limits_cpu_cores untyped
kube_pod_init_container_resource_limits_cpu_cores{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="2a82ed12-a31a-427a-adb9-d14cf6a4a063",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 0.1 1675856675021
# TYPE kube_pod_init_container_resource_limits_memory_bytes untyped
kube_pod_init_container_resource_limits_memory_bytes{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="a920ed2f-477d-4ad7-93d6-3222aabfece2",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1.073741824e+09 1675856675021
# TYPE kube_pod_init_container_resource_requests_cpu_cores untyped
kube_pod_init_container_resource_requests_cpu_cores{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="c7f7a05a-a1b5-4fd0-a611-8e2a0e7acbf6",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 0.25 1675856675021
# TYPE kube_pod_init_container_resource_requests_memory_bytes untyped
kube_pod_init_container_resource_requests_memory_bytes{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="c7f7a05a-a1b5-4fd0-a611-8e2a0e7acbf6",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 6.7108864e+07 1675856675021
# TYPE kube_pod_init_container_status_ready untyped
kube_pod_init_container_status_ready{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="64b6d309-44e3-4a41-8883-c15c7cc9bc4a",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1 1675856675021
kube_pod_init_container_status_ready{container="test-container",endpoint="http",instance="test-node",job="test-job",namespace="test-namespace",pod="test-pod",service="test-service",uid="bafeef2c-1292-4a5e-a92c-d709480b04b6",prometheus="prometheus-system/kube-prometheus-kube-prome-prometheus",prometheus_replica="prometheus-kube-prometheus-kube-prome-prometheus-0"} 1 1675856675021
Expand Down
3 changes: 2 additions & 1 deletion build/swi-k8s-opentelemetry-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dist:
name: swi-k8s-opentelemetry-collector
description: "SolarWinds distribution for OpenTelemetry"
otelcol_version: "0.81.0"
version: "0.8.2"
version: "0.8.4"
exporters:
- gomod: go.opentelemetry.io/collector/exporter/otlpexporter v0.81.0

Expand All @@ -14,6 +14,7 @@ receivers:
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8seventsreceiver v0.81.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver v0.81.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/journaldreceiver v0.81.0
- gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowseventlogreceiver v0.81.0

processors:
- gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.81.0
Expand Down
24 changes: 24 additions & 0 deletions deploy/helm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Fixed

- Detection of Node name for Fargate Nodes's metrics

## [2.8.0-alpha.3] - 2023-10-06

### Changed

- Changing log message attributes to respect OTEL log format

### Fixed
- Fixing nodeselector for kube-state-metrics so that it is deployed on linux nodes only

## [2.8.0-alpha.2] - 2023-09-14

### Added

- Add monitoring windows node logs
## [2.8.0-alpha.1] - 2023-09-11

### Added

- Added windows container for logs monitoring

## [2.7.0] - 2023-09-04

### Added
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: swo-k8s-collector
version: 2.7.0
appVersion: "0.8.2"
version: 2.8.0-alpha.3
appVersion: "0.8.3"
description: SolarWinds Kubernetes Integration
keywords:
- monitoring
Expand Down
35 changes: 21 additions & 14 deletions deploy/helm/logs-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ processors:
- k8s.namespace.name
- k8s.pod.name
- k8s.pod.uid
- host.hostname
- host.name
- service.name


Expand Down Expand Up @@ -62,7 +62,7 @@ processors:
- key: k8s.node.name
value: ${NODE_NAME}
action: insert

{{- if and (not .isWindows) .Values.otel.logs.journal }}
resource/journal:
attributes:

Expand Down Expand Up @@ -92,22 +92,20 @@ processors:
- key: k8s.node.name
value: ${NODE_NAME}
action: insert
{{- end }}
transform/syslogify:
error_mode: ignore
log_statements:
- context: log
statements:
- set( attributes["syslog.facility"], 1 )
- set( attributes["syslog.version"], 1 )
- set( attributes["host.hostname"], attributes["k8s.pod.name"])
- set( attributes["host.name"], attributes["k8s.pod.name"])
- set( attributes["service.name"], attributes["k8s.container.name"])
- set( attributes["syslog.procid"], attributes["run_id"])
- set( attributes["syslog.msgid"], attributes["stream"])

batch:
{{ toYaml .Values.otel.logs.batch | indent 4 }}

receivers:
{{- if and (not .isWindows) .Values.otel.logs.journal }}
journald/runlogs:
directory: /run/log/journal
units:
Expand All @@ -120,10 +118,16 @@ receivers:
- kubelet
- docker
- containerd
{{- end}}
filelog:
include: [ /var/log/pods/*/*/*.log ]
# Exclude collector container's logs. The file format is /var/log/pods/<namespace_name>_<pod_name>_<pod_uid>/<container_name>/<run_id>.log
{{- if (.isWindows) }}
include: [ "\\var\\log\\pods\\*\\*\\*.log" ]
exclude: [ "\\var\\log\\pods\\${POD_NAMESPACE}_${POD_NAME}*_*\\swi-opentelemetry-collector\\*.log" ]
{{- else }}
include: [ "/var/log/pods/*/*/*.log" ]
# Exclude collector container's logs. The file format is /var/log/pods/<namespace_name>_<pod_name>_<pod_uid>/<container_name>/<run_id>.log
exclude: [ "/var/log/pods/${POD_NAMESPACE}_${POD_NAME}*_*/swi-opentelemetry-collector/*.log" ]
{{- end }}
start_at: {{ .Values.otel.logs.receiver.start_at }}
include_file_path: true
include_file_name: false
Expand Down Expand Up @@ -203,7 +207,11 @@ receivers:
# Extract metadata from file path
- type: regex_parser
id: extract-metadata-from-filepath
regex: '^.*\/(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]+)\/(?P<container_name>[^\._]+)\/(?P<run_id>\d+)\.log$'
{{- if (.isWindows) }}
regex: '^.*\\(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]+)\\(?P<container_name>[^\._]+)\\(?P<run_id>\d+)\.log$'
{{- else }}
regex: '^.*\/(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]+)\/(?P<container_name>[^\._]+)\/(?P<run_id>\d+)\.log$'
{{- end }}
parse_from: attributes["log.file.path"]

# Rename attributes
Expand All @@ -220,9 +228,8 @@ receivers:
- type: move
from: attributes.pod_name
to: attributes["k8s.pod.name"]
- type: move
from: attributes.run_id
to: attributes["run_id"]
- type: remove
field: attributes.run_id
- type: move
from: attributes.uid
to: attributes["k8s.pod.uid"]
Expand Down Expand Up @@ -256,7 +263,7 @@ service:
receivers:
- filelog
{{- end }}
{{- if .Values.otel.logs.journal }}
{{- if and (not .isWindows) .Values.otel.logs.journal }}
logs/2:
exporters:
- otlp
Expand Down
12 changes: 8 additions & 4 deletions deploy/helm/metrics-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ processors:
datapoint:
- 'attributes["container"] == "POD" and IsMatch(metric.name, "container_network_.*|k8s.container.*") == true'


# unify attributes
attributes/unify_node_attribute:
include:
Expand All @@ -72,9 +71,13 @@ processors:
from_attribute: kubernetes_io_hostname
action: insert
{{- end }}
- key: k8s.node.name
from_attribute: service.instance.id
action: insert

transform/unify_node_attribute:
metric_statements:
- context: datapoint
statements:
# use "service.instance.id" for Node name when the attributes/unify_node_attribute processor failed to provide it
- set(attributes["k8s.node.name"], resource.attributes["service.instance.id"]) where IsMatch(metric.name, "^(container_.*)|(kube_node_.*)|(kube_pod_info)|(kube_pod_container_resource_requests)|(kube_pod_container_resource_limits)|(kube_pod_init_container_resource_requests)|(kube_pod_init_container_resource_limits)$") == true and attributes["k8s.node.name"] == nil

attributes/unify_volume_attribute:
include:
Expand Down Expand Up @@ -1484,6 +1487,7 @@ service:
- transform
- filter/remove_internal
- attributes/unify_node_attribute
- transform/unify_node_attribute
- attributes/unify_volume_attribute
- attributes/identify_init_container
- attributes/identify_standard_container
Expand Down
21 changes: 21 additions & 0 deletions deploy/helm/templates/logs-collector-config-map-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.otel.logs.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.fullname" . }}-logs-config-windows
namespace: {{ .Release.Namespace }}
labels:
{{ include "common.labels" . | indent 4 }}
data:
logs.config: |
{{ tpl (.Files.Get "logs-collector-config.yaml") (merge . (dict "isWindows" 1)) | fromYaml | toYaml | indent 8 }}

logs_service.proto: |
{{ tpl (.Files.Get "opentelemetry-proto/opentelemetry/proto/collector/logs/v1/logs_service.proto") . | indent 8 }}
logs.proto: |
{{ tpl (.Files.Get "opentelemetry-proto/opentelemetry/proto/logs/v1/logs.proto") . | indent 8 }}
common.proto: |
{{ tpl (.Files.Get "opentelemetry-proto/opentelemetry/proto/common/v1/common.proto") . | indent 8 }}
resource.proto: |
{{ tpl (.Files.Get "opentelemetry-proto/opentelemetry/proto/resource/v1/resource.proto") . | indent 8 }}
{{- end }}
Loading

0 comments on commit 3b67305

Please sign in to comment.