-
Notifications
You must be signed in to change notification settings - Fork 545
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
Add influx push endpoint to mimir #10153
Merged
Merged
Changes from 55 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
444d34f
olegs base commits from #1971
alexgreenbank adb376a
move top level influx files
alexgreenbank 3db179f
latest wip
alexgreenbank 295fa8d
still WIP but better, still need to move to parserFunc() style
alexgreenbank d2897e3
it builds!
alexgreenbank c2fb679
tweaks and add span logging
alexgreenbank 593b2e2
more todo
alexgreenbank 31bf23d
further tweaks
alexgreenbank 2487a88
some fixes to tests
alexgreenbank 03e8e3c
rejigged error handling, tests passing
alexgreenbank 0bd8da8
add vendored influxdb code
alexgreenbank 4a76a11
lint
alexgreenbank 066c009
go mod sum vendor/modules.txt
alexgreenbank bec3a26
add a metric, add tenant info, other tweaks
alexgreenbank ac51def
various rework, still WIP
alexgreenbank 3a57dc6
propagate bytesRead down to caller and log and histogram
alexgreenbank 92379e4
remove comment now dealt with
alexgreenbank d44c71d
add defaults in error handling
alexgreenbank 591389e
Add note to docs about experimental Influx flag
alexgreenbank afbc357
Note influx endpoint as experimental too
alexgreenbank 847bcb9
test for specific errors received
alexgreenbank 320c467
bolster parser tests
alexgreenbank 730a7c3
Use literal chars rather than ascii codes
alexgreenbank de27d4b
remove unnecessary cast to int()
alexgreenbank af3def1
use mimirpb.PreallocTimeseries in influx parser
alexgreenbank d65b3a5
remove unnecessary tryUnwrap()
alexgreenbank 9d94276
Work on byteslice rather than chars
alexgreenbank 258fe0d
yoloString for label value as push code does not keep references to s…
alexgreenbank e5252d4
update go.sum
alexgreenbank f86691b
gah go.sum
alexgreenbank 32cc156
oops, missed removal of paramter to InfluxHandler()
alexgreenbank c798360
wrong metrics incremented
alexgreenbank 8d4e7ca
lint
alexgreenbank e915764
lint
alexgreenbank 013b3d6
go mod tidy && go mod vendor
alexgreenbank 3c5a166
go.sum conflict
alexgreenbank 773722f
merge latest main
alexgreenbank 6143162
make doc
alexgreenbank ac4e491
Merge branch 'main' into alexg/influx-push-handler
alexgreenbank 767695a
make influx config hidden/experimental
alexgreenbank 419d327
fix byteslice handling in replaceInvalidChars()
alexgreenbank 9e9e117
remove unnecessary TODOs
alexgreenbank 0da4b8f
influx: happy path e2e test
alexgreenbank c470fb3
lint
alexgreenbank c44d321
consolidate logging
alexgreenbank 537fa37
CHANGELOG
alexgreenbank 14bae20
about-versioning.md
alexgreenbank b951127
Merge branch 'main' into alexg/influx-push-handler
alexgreenbank 9d035f5
merge main
alexgreenbank c31c191
Merge branch 'alexg/influx-push-handler' of github.com:grafana/mimir …
alexgreenbank 0872e6a
Update pkg/distributor/influxpush/parser.go
alexgreenbank de92ac5
Update pkg/distributor/influxpush/parser.go
alexgreenbank 0e6cea6
Update pkg/distributor/influxpush/parser.go
alexgreenbank 8afdd9b
fix parsing string replacing code
alexgreenbank 7018f72
fix merge conflicts
alexgreenbank d81ac52
fix nits
alexgreenbank 332576e
Merge branch 'main' into alexg/influx-push-handler
alexgreenbank 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
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,100 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
//go:build requires_docker | ||
|
||
package integration | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
"time" | ||
|
||
"github.com/grafana/e2e" | ||
e2edb "github.com/grafana/e2e/db" | ||
"github.com/prometheus/common/model" | ||
"github.com/prometheus/prometheus/model/labels" | ||
"github.com/prometheus/prometheus/prompb" | ||
v1 "github.com/prometheus/prometheus/web/api/v1" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/grafana/mimir/integration/e2emimir" | ||
) | ||
|
||
func TestInfluxIngestion(t *testing.T) { | ||
t.Helper() | ||
|
||
s, err := e2e.NewScenario(networkName) | ||
require.NoError(t, err) | ||
defer s.Close() | ||
|
||
// Start dependencies. | ||
minio := e2edb.NewMinio(9000, blocksBucketName) | ||
require.NoError(t, s.StartAndWaitReady(minio)) | ||
|
||
// Start Mimir components. | ||
require.NoError(t, copyFileToSharedDir(s, "docs/configurations/single-process-config-blocks.yaml", mimirConfigFile)) | ||
|
||
// Start Mimir in single binary mode, reading the config from file and overwriting | ||
// the backend config to make it work with Minio. | ||
flags := mergeFlags( | ||
DefaultSingleBinaryFlags(), | ||
BlocksStorageFlags(), | ||
BlocksStorageS3Flags(), | ||
map[string]string{ | ||
"-distributor.influx-endpoint-enabled": "true", | ||
}, | ||
) | ||
|
||
mimir := e2emimir.NewSingleBinary("mimir-1", flags, e2emimir.WithConfigFile(mimirConfigFile), e2emimir.WithPorts(9009, 9095)) | ||
require.NoError(t, s.StartAndWaitReady(mimir)) | ||
|
||
c, err := e2emimir.NewClient(mimir.HTTPEndpoint(), mimir.HTTPEndpoint(), "", "", "user-1") | ||
require.NoError(t, err) | ||
|
||
// Push some series to Mimir. | ||
now := time.Now() | ||
|
||
series, expectedVector, expectedMatrix := generateFloatSeries("series_f1", now, prompb.Label{Name: "foo", Value: "bar"}) | ||
// Fix up the expectation as Influx values seem to be rounded to millionths | ||
for _, s := range expectedVector { | ||
s.Metric[model.LabelName("__mimir_source__")] = model.LabelValue("influx") | ||
s.Value = model.SampleValue(math.Round(float64(s.Value)*1000000) / 1000000.0) | ||
} | ||
// Fix up the expectation as Influx values seem to be rounded to millionths | ||
for im, s := range expectedMatrix { | ||
for iv, v := range s.Values { | ||
expectedMatrix[im].Values[iv].Value = model.SampleValue(math.Round(float64(v.Value)*1000000) / 1000000.0) | ||
} | ||
} | ||
|
||
res, err := c.PushInflux(series) | ||
require.NoError(t, err) | ||
require.Equal(t, 204, res.StatusCode) | ||
|
||
// Check metric to track Influx requests | ||
require.NoError(t, mimir.WaitSumMetricsWithOptions(e2e.Equals(1), []string{"cortex_distributor_influx_requests_total"}, e2e.WithLabelMatchers( | ||
labels.MustNewMatcher(labels.MatchEqual, "user", "user-1")))) | ||
|
||
// Query the series. | ||
result, err := c.Query("series_f1", now) | ||
require.NoError(t, err) | ||
require.Equal(t, model.ValVector, result.Type()) | ||
assert.Equal(t, expectedVector, result.(model.Vector)) | ||
|
||
labelValues, err := c.LabelValues("foo", v1.MinTime, v1.MaxTime, nil) | ||
require.NoError(t, err) | ||
require.Equal(t, model.LabelValues{"bar"}, labelValues) | ||
|
||
labelNames, err := c.LabelNames(v1.MinTime, v1.MaxTime, nil) | ||
require.NoError(t, err) | ||
require.Equal(t, []string{"__mimir_source__", "__name__", "foo"}, labelNames) | ||
|
||
rangeResult, err := c.QueryRange("series_f1", now.Add(-15*time.Minute), now, 15*time.Second) | ||
require.NoError(t, err) | ||
require.Equal(t, model.ValMatrix, rangeResult.Type()) | ||
require.Equal(t, expectedMatrix, rangeResult.(model.Matrix)) | ||
|
||
// No metadata to query, but we do the query anyway. | ||
_, err = c.GetPrometheusMetadata() | ||
require.NoError(t, err) | ||
} |
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.
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.
Please move this to the Grafana Mimir section below.
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.
Done.