-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic working example * increase default sample backoff to 1.25s * increase check frequency * tests for ready * review feedback * finish initial implementation * sign drone * fix lint issues * Update pkg/crow/samples.go
- Loading branch information
Showing
15 changed files
with
986 additions
and
38 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
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,11 @@ | ||
FROM golang:1.16-buster as build | ||
COPY . /src/agent | ||
WORKDIR /src/agent | ||
ARG RELEASE_BUILD=true | ||
ARG IMAGE_TAG | ||
|
||
RUN make clean && make IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false grafana-agent-crow | ||
|
||
FROM debian:buster-slim | ||
COPY --from=build /src/agent/cmd/grafana-agent-crow/grafana-agent-crow /bin/grafana-agent-crow | ||
ENTRYPOINT ["/bin/grafana-agent-crow"] |
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,24 @@ | ||
FROM --platform=$BUILDPLATFORM rfratto/seego:latest as build | ||
ARG TARGETPLATFORM | ||
ARG BUILDPLATFORM | ||
|
||
# Use custom Go version instead of one prepacked in seego | ||
ENV GOLANG_VERSION 1.16 | ||
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz | ||
ENV GOLANG_DOWNLOAD_SHA256 013a489ebb3e24ef3d915abe5b94c3286c070dfe0818d5bca8108f1d6e8440d2 | ||
RUN rm -rf /usr/local/go \ | ||
&& curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ | ||
&& echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ | ||
&& tar -C /usr/local -xzf golang.tar.gz \ | ||
&& rm golang.tar.gz | ||
|
||
COPY . /src/agent | ||
WORKDIR /src/agent | ||
ARG RELEASE_BUILD=true | ||
ARG IMAGE_TAG | ||
|
||
RUN make clean && IMAGE_TAG=${IMAGE_TAG} RELEASE_BUILD=${RELEASE_BUILD} BUILD_IN_CONTAINER=false DRONE=true make grafana-agent-crow | ||
|
||
FROM debian:buster-slim | ||
COPY --from=build /src/agent/cmd/grafana-agent-crow/grafana-agent-crow /bin/grafana-agent-crow | ||
ENTRYPOINT ["/bin/grafana-agent-crow"] |
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,81 @@ | ||
// Comand grafana-agent-crow is a correctness checker tool that validates that | ||
// scraped metrics are delivered to a remote_write endpoint. Inspired by Loki | ||
// Canary and Cortex test-exporter. | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
// Adds version information | ||
_ "github.com/grafana/agent/pkg/build" | ||
|
||
"github.com/go-kit/kit/log/level" | ||
"github.com/grafana/agent/pkg/crow" | ||
"github.com/grafana/agent/pkg/util" | ||
"github.com/prometheus/client_golang/prometheus" | ||
"github.com/prometheus/client_golang/prometheus/promhttp" | ||
"github.com/prometheus/common/version" | ||
"github.com/weaveworks/common/server" | ||
) | ||
|
||
func init() { | ||
prometheus.MustRegister(version.NewCollector("grafana_agent_crow")) | ||
} | ||
|
||
func main() { | ||
var ( | ||
fs = flag.NewFlagSet(os.Args[0], flag.ExitOnError) | ||
|
||
serverCfg server.Config | ||
crowCfg crow.Config | ||
showVersion bool | ||
) | ||
|
||
serverCfg.RegisterFlags(fs) | ||
crowCfg.RegisterFlagsWithPrefix(fs, "crow.") | ||
fs.BoolVar(&showVersion, "version", false, "show version") | ||
|
||
if err := fs.Parse(os.Args[1:]); err != nil { | ||
fmt.Fprintln(os.Stderr, "failed to parse flags", err) | ||
os.Exit(1) | ||
} | ||
if showVersion { | ||
fmt.Println(version.Print(os.Args[0])) | ||
os.Exit(0) | ||
} | ||
|
||
l := util.NewLogger(&serverCfg) | ||
crowCfg.Log = l | ||
serverCfg.Log = util.GoKitLogger(l) | ||
|
||
s, err := server.New(serverCfg) | ||
if err != nil { | ||
level.Error(l).Log("msg", "failed to initialize server", "err", err) | ||
os.Exit(1) | ||
} | ||
|
||
c, err := crow.New(crowCfg) | ||
if err != nil { | ||
level.Error(l).Log("msg", "failed to initialize crow", "err", err) | ||
os.Exit(1) | ||
} | ||
defer c.Stop() | ||
|
||
// The server comes with a /metrics endpoint by default using s.Registerer. | ||
// Create a /validate endpoint to handle our validation metrics. | ||
validator := prometheus.NewRegistry() | ||
s.HTTP.Handle("/validate", promhttp.HandlerFor(validator, promhttp.HandlerOpts{ | ||
EnableOpenMetrics: true, | ||
})) | ||
|
||
// Register crow's metrics to /metrics and /valiate respectively. | ||
s.Registerer.MustRegister(c.StateMetrics()) | ||
validator.MustRegister(c.TestMetrics()) | ||
|
||
if err := s.Run(); err != nil { | ||
level.Error(l).Log("msg", "server exited with error", "err", err) | ||
os.Exit(1) | ||
} | ||
} |
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
Oops, something went wrong.