Skip to content

Commit

Permalink
ain merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdurham committed Nov 16, 2023
2 parents bf58635 + 461a4b2 commit 26d7eda
Show file tree
Hide file tree
Showing 121 changed files with 1,009 additions and 2,563 deletions.
128 changes: 64 additions & 64 deletions .drone/drone.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.21.0"
go-version: "1.21"
- name: Set OTEL Exporter Endpoint
run: echo "OTEL_EXPORTER_ENDPOINT=http://172.17.0.1:8080" >> $GITHUB_ENV
- name: Run tests
run: make integration-test
run: make integration-test
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
name: Test
strategy:
matrix:
platform: [macos-latest]
platform: [macos-latest-xlarge]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: "1.21.0"
go-version: "1.21"
cache: true
- name: Test
run: make GO_TAGS="nodocker" test
28 changes: 23 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ Main (unreleased)
- renamed 3 metrics starting with `mysql_perf_schema_transaction_` to start with `mysql_perf_schema_transactions_` to be consistent with column names.
- exposing only server's own stats by matching `MEMBER_ID` with `@@server_uuid` resulting "member_id" label to be dropped.

### Other changes

- Bump `mysqld_exporter` version to v0.15.0. (@marctc)
- Bump `github-exporter` version to 1.0.6. (@marctc)

### Features

- Added a new `stage.decolorize` stage to `loki.process` component which
Expand Down Expand Up @@ -63,6 +58,8 @@ Main (unreleased)
- `otelcol.processor.filter` - filters OTLP telemetry data using OpenTelemetry
Transformation Language (OTTL). (@hainenber)

- Agent Management: Introduce support for remotely managed external labels for logs. (@jcreixell)

### Enhancements

- The `loki.write` WAL now has snappy compression enabled by default. (@thepalbi)
Expand Down Expand Up @@ -97,6 +94,8 @@ Main (unreleased)

- Added support for replaying not sent data for `loki.write` when WAL is enabled. (@thepalbi)

- Make the result of 'discovery.kubelet' support pods that without ports, such as k8s control plane static pods. (@masonmei)

- Added support for unicode strings in `pyroscope.ebpf` python profiles. (@korniltsev)

- Improved resilience of graph evaluation in presence of slow components. (@thampiotr)
Expand Down Expand Up @@ -143,6 +142,25 @@ Main (unreleased)
resulting in remote write sending the exemplar first and Prometheus failing to ingest it due to missing
series. (@krajorama)

- Fixed an issue in the static config converter where exporter instance values
were not being mapped when translating to flow. (@erikbaranowski)

- Fix a bug which prevented Agent from running `otelcol.exporter.loadbalancing`
with a `routing_key` of `traceID`. (@ptodev)

- Added Kubernetes service resolver to static node's loadbalancing exporter
and to Flow's `otelcol.exporter.loadbalancing`. (@ptodev)

### Other changes

- Bump `mysqld_exporter` version to v0.15.0. (@marctc)

- Bump `github-exporter` version to 1.0.6. (@marctc)

- Use Go 1.21.4 for builds. (@rfratto)

- Change User-Agent header for outbound requests to include agent-mode, goos, and deployment mode. Example `GrafanaAgent/v0.38.0 (flow; linux; docker)` (@captncraig)

- `loki.source.windowsevent` and `loki.source.*` changed to use a more robust positions file to prevent corruption on reboots when writing
the positions file. (@mattdurham)

Expand Down
2 changes: 1 addition & 1 deletion build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FROM alpine:3.17 as helm
RUN apk add --no-cache helm

# Dependency: Go and Go dependencies
FROM golang:1.21.3-bullseye as golang
FROM golang:1.21.4-bullseye as golang

# Keep in sync with cmd/grafana-agent-operator/DEVELOPERS.md
ENV CONTROLLER_GEN_VERSION v0.9.2
Expand Down
2 changes: 1 addition & 1 deletion build-image/windows/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM library/golang:1.21.3-windowsservercore-1809
FROM library/golang:1.21.4-windowsservercore-1809

SHELL ["powershell", "-command"]

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agent-operator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.3 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
3 changes: 2 additions & 1 deletion cmd/grafana-agent/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.3 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down Expand Up @@ -47,4 +47,5 @@ COPY cmd/grafana-agent/agent-local-config.yaml /etc/agent/agent.yaml


ENTRYPOINT ["/bin/grafana-agent"]
ENV AGENT_DEPLOY_MODE=docker
CMD ["--config.file=/etc/agent/agent.yaml", "--metrics.wal-directory=/etc/agent/data"]
2 changes: 1 addition & 1 deletion cmd/grafana-agent/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.3-windows as builder
FROM grafana/agent-build-image:0.30.4-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# default when running `docker buildx build` or when DOCKER_BUILDKIT=1 is set
# in environment variables.

FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.3 as build
FROM --platform=$BUILDPLATFORM grafana/agent-build-image:0.30.4 as build
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETOS
Expand Down
2 changes: 1 addition & 1 deletion cmd/grafana-agentctl/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM grafana/agent-build-image:0.30.3-windows as builder
FROM grafana/agent-build-image:0.30.4-windows as builder
ARG VERSION
ARG RELEASE_BUILD=1

Expand Down
4 changes: 2 additions & 2 deletions component/common/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/go-kit/log"
commoncfg "github.com/grafana/agent/component/common/config"
"github.com/grafana/agent/pkg/build"
"github.com/grafana/agent/internal/useragent"
"github.com/grafana/agent/pkg/flow/logging/level"
promconfig "github.com/prometheus/common/config"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -79,7 +79,7 @@ func (args *ClientArguments) BuildRESTConfig(l log.Logger) (*rest.Config, error)
}
}

cfg.UserAgent = fmt.Sprintf("GrafanaAgent/%s", build.Version)
cfg.UserAgent = useragent.Get()
cfg.ContentType = "application/vnd.kubernetes.protobuf"

return cfg, nil
Expand Down
6 changes: 3 additions & 3 deletions component/common/loki/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import (
"time"

"github.com/go-kit/log"
"github.com/grafana/agent/internal/useragent"
"github.com/grafana/agent/pkg/flow/logging/level"
"github.com/grafana/dskit/backoff"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/config"
"github.com/prometheus/common/model"

"github.com/grafana/agent/component/common/loki"
"github.com/grafana/agent/pkg/build"
"github.com/grafana/agent/pkg/util"
lokiutil "github.com/grafana/loki/pkg/util"
)
Expand All @@ -47,7 +47,7 @@ const (

var Reasons = []string{ReasonGeneric, ReasonRateLimited, ReasonStreamLimited, ReasonLineTooLong}

var UserAgent = fmt.Sprintf("GrafanaAgent/%s", build.Version)
var userAgent = useragent.Get()

type Metrics struct {
encodedBytes *prometheus.CounterVec
Expand Down Expand Up @@ -419,7 +419,7 @@ func (c *client) send(ctx context.Context, tenantID string, buf []byte) (int, er
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", contentType)
req.Header.Set("User-Agent", UserAgent)
req.Header.Set("User-Agent", userAgent)

// If the tenant ID is not empty promtail is running in multi-tenant mode, so
// we should send it to Loki
Expand Down
2 changes: 1 addition & 1 deletion component/common/loki/client/queue_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ func (c *queueClient) send(ctx context.Context, tenantID string, buf []byte) (in
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", contentType)
req.Header.Set("User-Agent", UserAgent)
req.Header.Set("User-Agent", userAgent)

// If the tenant ID is not empty promtail is running in multi-tenant mode, so
// we should send it to Loki
Expand Down
40 changes: 40 additions & 0 deletions component/discovery/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
podNameLabel = metaLabelPrefix + "pod_name"
podIPLabel = metaLabelPrefix + "pod_ip"
podContainerNameLabel = metaLabelPrefix + "pod_container_name"
podContainerIDLabel = metaLabelPrefix + "pod_container_id"
podContainerImageLabel = metaLabelPrefix + "pod_container_image"
podContainerPortNameLabel = metaLabelPrefix + "pod_container_port_name"
podContainerPortNumberLabel = metaLabelPrefix + "pod_container_port_number"
Expand Down Expand Up @@ -214,13 +215,35 @@ func (d *Discovery) buildPodTargetGroup(pod v1.Pod) *targetgroup.Group {
containers := append(pod.Spec.Containers, pod.Spec.InitContainers...)
for i, c := range containers {
isInit := i >= len(pod.Spec.Containers)
cStatuses := &pod.Status.ContainerStatuses
if isInit {
cStatuses = &pod.Status.InitContainerStatuses
}
cID := d.findPodContainerID(cStatuses, c.Name)

// If no ports are defined for the container, create an anonymous
// target per container.
if len(c.Ports) == 0 {
// We don't have a port so we just set the address label to the pod IP.
// The user has to add a port manually.
tg.Targets = append(tg.Targets, model.LabelSet{
model.AddressLabel: lv(pod.Status.PodIP),
podContainerNameLabel: lv(c.Name),
podContainerIDLabel: lv(cID),
podContainerImageLabel: lv(c.Image),
podContainerIsInit: lv(strconv.FormatBool(isInit)),
})
continue
}

for _, port := range c.Ports {
ports := strconv.FormatUint(uint64(port.ContainerPort), 10)
addr := net.JoinHostPort(pod.Status.PodIP, ports)

tg.Targets = append(tg.Targets, model.LabelSet{
model.AddressLabel: lv(addr),
podContainerNameLabel: lv(c.Name),
podContainerIDLabel: lv(cID),
podContainerImageLabel: lv(c.Image),
podContainerPortNumberLabel: lv(ports),
podContainerPortNameLabel: lv(port.Name),
Expand All @@ -233,6 +256,23 @@ func (d *Discovery) buildPodTargetGroup(pod v1.Pod) *targetgroup.Group {
return tg
}

func (p *Discovery) findPodContainerStatus(statuses *[]v1.ContainerStatus, containerName string) (*v1.ContainerStatus, error) {
for _, s := range *statuses {
if s.Name == containerName {
return &s, nil
}
}
return nil, fmt.Errorf("cannot find container with name %v", containerName)
}

func (p *Discovery) findPodContainerID(statuses *[]v1.ContainerStatus, containerName string) string {
cStatus, err := p.findPodContainerStatus(statuses, containerName)
if err != nil {
return ""
}
return cStatus.ContainerID
}

func (d *Discovery) podInTargetNamespaces(pod v1.Pod) bool {
for _, ns := range d.targetNamespaces {
if pod.Namespace == ns {
Expand Down
17 changes: 17 additions & 0 deletions component/discovery/kubelet/kubelet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,20 @@ func newPod(name, namespace string) v1.Pod {
},
}
}

func TestDiscoveryPodWithoutPod(t *testing.T) {
pod1 := newPod("pod-1", "namespace-1")
pod2 := newPod("pod-2", "namespace-2")
pod1.Spec.Containers[0].Ports = []v1.ContainerPort{}

podList1 := v1.PodList{
Items: []v1.Pod{pod1, pod2},
}

kubeletDiscovery, err := NewKubeletDiscovery(DefaultConfig)
require.NoError(t, err)

_, err = kubeletDiscovery.refresh(podList1)
require.NoError(t, err)
require.Len(t, kubeletDiscovery.discoveredPodSources, 2)
}
4 changes: 2 additions & 2 deletions component/loki/source/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
flow_relabel "github.com/grafana/agent/component/common/relabel"
"github.com/grafana/agent/component/discovery"
dt "github.com/grafana/agent/component/loki/source/docker/internal/dockertarget"
"github.com/grafana/agent/pkg/build"
"github.com/grafana/agent/internal/useragent"
"github.com/grafana/agent/pkg/flow/logging/level"
"github.com/prometheus/common/config"
"github.com/prometheus/common/model"
Expand All @@ -40,7 +40,7 @@ func init() {
})
}

var userAgent = fmt.Sprintf("GrafanaAgent/%s", build.Version)
var userAgent = useragent.Get()

const (
dockerLabel = model.MetaLabelPrefix + "docker_"
Expand Down
3 changes: 0 additions & 3 deletions component/loki/write/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/grafana/agent/component/common/loki/client"
"github.com/grafana/agent/component/common/loki/limit"
"github.com/grafana/agent/component/common/loki/wal"
"github.com/grafana/agent/pkg/build"
)

func init() {
Expand All @@ -25,8 +24,6 @@ func init() {
return New(opts, args.(Arguments))
},
})

client.UserAgent = fmt.Sprintf("GrafanaAgent/%s", build.Version)
}

// Arguments holds values which are used to configure the loki.write component.
Expand Down
Loading

0 comments on commit 26d7eda

Please sign in to comment.