-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grafana Agent Crow #773
Merged
Merged
Grafana Agent Crow #773
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a56c980
basic working example
rfratto 0332dd2
increase default sample backoff to 1.25s
rfratto e1d03cf
increase check frequency
rfratto 45253d8
tests for ready
rfratto 468873e
review feedback
rfratto 3590cfa
finish initial implementation
rfratto cd6142e
sign drone
rfratto 309231b
fix lint issues
rfratto 7f593f2
Update pkg/crow/samples.go
rfratto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,23 @@ server: | |
|
||
prometheus: | ||
global: | ||
scrape_interval: 5s | ||
scrape_interval: 30s | ||
configs: | ||
- name: test | ||
host_filter: false | ||
scrape_configs: | ||
- job_name: crow | ||
static_configs: | ||
- targets: ['crow:8080'] | ||
labels: | ||
cluster: 'docker_compose' | ||
container: 'crow' | ||
pod: 'crow' | ||
- job_name: crow_validate | ||
metrics_path: /validate | ||
static_configs: | ||
- targets: ['crow:8080'] | ||
|
||
- job_name: local_scrape | ||
static_configs: | ||
- targets: ['127.0.0.1:12345'] | ||
|
@@ -43,10 +55,6 @@ prometheus: | |
container: 'avalanche-3' | ||
remote_write: | ||
- url: http://cortex:9009/api/prom/push | ||
- name: tempo | ||
host_filter: false | ||
remote_write: | ||
- url: http://cortex:9009/api/prom/push | ||
|
||
loki: | ||
configs: | ||
|
@@ -88,8 +96,5 @@ tempo: | |
spans: true | ||
processes: true | ||
roots: true | ||
labels: | ||
- svc | ||
- status | ||
Comment on lines
-91
to
-93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
spanmetrics: | ||
prom_instance: tempo | ||
prom_instance: test |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out flags after
--
aren't read and you can't omit the--
otherwise-online
will be passed to every package, even packages that don't have them defined. Build tags are the best choice here.