8000 Sync upstream Prometheus at 898af61 by charleskorn · Pull Request #840 · grafana/mimir-prometheus · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sync upstream Prometheus at 898af61 #840

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

Merged
merged 20 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
05713e9
feat(scaleway-sd): add labels for multiple routed IPs
Codelax Jun 5, 2024
7766f2f
tests(scaleway-sd): add case with multiple routed ips
Codelax Jun 7, 2024
c7378c5
docs(scaleway-sd): document public ipv4 and ipv6 addresses
Codelax Jun 13, 2024
9eac82d
fix(scaleway-sd): do not use ip list to fill server address
Codelax Jun 13, 2024
a307cd4
fix(scaleway-sd): do not fill public_ipv4 with ipv6
Codelax Jun 13, 2024
b472ce7
chore: enable early-return from revive
mmorel-35 Feb 10, 2025
329ec68
util/httputil: reduce heap allocations in newCompressedResponseWriter…
jub0bs Feb 11, 2025
de6add2
Merge pull request #14228 from Codelax/sd-scaleway-routed-ips
machine424 Feb 11, 2025
8baad1a
Bump promci to latest to avoid deprecated actions/cache CI issue. (#1…
bwplotka Feb 11, 2025
6518941
promql: Expose problem with histogram counter resets in subquery
beorn7 Feb 6, 2025
14bb63c
promql: Fix counter reset detection in subqueries with histograms
beorn7 Feb 6, 2025
13c05a3
Merge pull request #16007 from mmorel-35/revive/early-return
beorn7 Feb 11, 2025
906f6a3
Merge pull request #15987 from prometheus/beorn7/histogram
beorn7 Feb 11, 2025
a944fa1
Make theme switcher a single three-state toggle button (#16000)
juliusv Feb 12, 2025
a323c23
set ttlAutopurge to true as ttl is set for codemirror prometheus clie…
jgbernalp Feb 12, 2025
00b69ef
model/textparse: Change parser interface Metric(...) string to Labels…
bwplotka Feb 12, 2025
8fe24ce
ci: Add GH action that clicks "enable auto-merge" on dependabot PRs (… 8000
bwplotka Feb 12, 2025
509b978
single-button-theme-toggle-and-responsive-logo (#16021)
amanycodes Feb 12, 2025
898af61
promtool: support creating tsdb blocks from a pipe (#16011)
n-peugnet Feb 13, 2025
3b5fe59
Merge commit '898af61' into charleskorn/update-prometheus
charleskorn Mar 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/automerge-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Dependabot auto-merge
on: pull_request

concurrency:
group: ${{ github.workflow }}-${{ (github.event.pull_request && github.event.pull_request.number) || github.ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
dependabot:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository_owner == 'prometheus' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2.3.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ linters-settings:
- allowTypesBefore: "*testing.T,testing.TB"
- name: context-keys-type
- name: dot-imports
- name: early-return
arguments:
- "preserveScope"
# A lot of false positives: incorrectly identifies channel draining as "empty code block".
# See https://github.com/mgechev/revive/issues/386
- name: empty-block
Expand All @@ -139,13 +142,17 @@ linters-settings:
- name: exported
- name: increment-decrement
- name: indent-error-flow
arguments:
- "preserveScope"
- name: package-comments
# TODO(beorn7): Currently, we have a lot of missing package doc comments. Maybe we should have them.
disabled: true
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
arguments:
- "preserveScope"
- name: time-naming
- name: unexported-return
- name: unreachable-code
Expand Down
4 changes: 2 additions & 2 deletions cmd/promtool/backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func createBlocks(input []byte, mint, maxt, maxBlockDuration int64, maxSamplesIn
_, ts, v := p.Series()
if ts == nil {
l := labels.Labels{}
p.Metric(&l)
p.Labels(&l)
return fmt.Errorf("expected timestamp for series %v, got none", l)
}
if *ts < t {
Expand All @@ -163,7 +163,7 @@ func createBlocks(input []byte, mint, maxt, maxBlockDuration int64, maxSamplesIn
}

l := labels.Labels{}
p.Metric(&l)
p.Labels(&l)

lb.Reset(l)
for name, value := range customLabels {
Expand Down
20 changes: 17 additions & 3 deletions cmd/promtool/tsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,17 +826,31 @@ func checkErr(err error) int {
}

func backfillOpenMetrics(path, outputDir string, humanReadable, quiet bool, maxBlockDuration time.Duration, customLabels map[string]string) int {
inputFile, err := fileutil.OpenMmapFile(path)
var buf []byte
info, err := os.Stat(path)
if err != nil {
return checkErr(err)
}
defer inputFile.Close()
if info.Mode()&(os.ModeNamedPipe|os.ModeCharDevice) != 0 {
// Read the pipe chunks by chunks as it cannot be mmap-ed
buf, err = os.ReadFile(path)
if err != nil {
return checkErr(err)
}
} else {
inputFile, err := fileutil.OpenMmapFile(path)
if err != nil {
return checkErr(err)
}
defer inputFile.Close()
buf = inputFile.Bytes()
}

if err := os.MkdirAll(outputDir, 0o777); err != nil {
return checkErr(fmt.Errorf("create output dir: %w", err))
}

return checkErr(backfill(5000, inputFile.Bytes(), outputDir, humanReadable, quiet, maxBlockDuration, customLabels))
return checkErr(backfill(5000, buf, outputDir, humanReadable, quiet, maxBlockDuration, customLabels))
}

func displayHistogram(dataType string, datas []int, total int) {
Expand Down
69 changes: 69 additions & 0 deletions cmd/promtool/tsdb_posix_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright 2017 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !windows

package main

import (
"bytes"
"io"
"math"
"os"
"path"
"syscall"
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/prometheus/prometheus/tsdb"
)

func TestTSDBDumpOpenMetricsRoundTripPipe(t *testing.T) {
initialMetrics, err := os.ReadFile("testdata/dump-openmetrics-roundtrip-test.prom")
require.NoError(t, err)
initialMetrics = normalizeNewLine(initialMetrics)

pipeDir := t.TempDir()
dbDir := t.TempDir()

// create pipe
pipe := path.Join(pipeDir, "pipe")
err = syscall.Mkfifo(pipe, 0o666)
require.NoError(t, err)

go func() {
// open pipe to write
in, err := os.OpenFile(pipe, os.O_WRONLY, os.ModeNamedPipe)
require.NoError(t, err)
defer func() { require.NoError(t, in.Close()) }()
_, err = io.Copy(in, bytes.NewReader(initialMetrics))
require.NoError(t, err)
}()

// Import samples from OM format
code := backfillOpenMetrics(pipe, dbDir, false, false, 2*time.Hour, map[string]string{})
require.Equal(t, 0, code)
db, err := tsdb.Open(dbDir, nil, nil, tsdb.DefaultOptions(), nil)
require.NoError(t, err)
t.Cleanup(func() {
require.NoError(t, db.Close())
})

// Dump the blocks into OM format
dumpedMetrics := getDumpedSamples(t, dbDir, "", math.MinInt64, math.MaxInt64, []string{"{__name__=~'(?s:.*)'}"}, formatSeriesSetOpenMetrics)

// Should get back the initial metrics.
require.Equal(t, string(initialMetrics), dumpedMetrics)
}
5 changes: 2 additions & 3 deletions discovery/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,10 @@ func (d *Discovery) vmToLabelSet(ctx context.Context, client client, vm virtualM
networkInterface, err = client.getVMScaleSetVMNetworkInterfaceByID(ctx, nicID, vm.ScaleSet, vm.InstanceID)
}
if err != nil {
if errors.Is(err, errorNotFound) {
d.logger.Warn("Network interface does not exist", "name", nicID, "err", err)
} else {
if !errors.Is(err, errorNotFound) {
return nil, err
}
d.logger.Warn("Network interface does not exist", "name", nicID, "err", err)
// Get out of this routine because we cannot continue without a network interface.
return nil, nil
}
Expand Down
9 changes: 4 additions & 5 deletions discovery/linode/linode.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,12 @@ func (d *Discovery) refresh(ctx context.Context) ([]*targetgroup.Group, error) {
events, err := d.client.ListEvents(ctx, &eventsOpts)
if err != nil {
var e *linodego.Error
if errors.As(err, &e) && e.Code == http.StatusUnauthorized {
// If we get a 401, the token doesn't have `events:read_only` scope.
// Disable event polling and fallback to doing a full refresh every interval.
d.eventPollingEnabled = false
} else {
if !(errors.As(err, &e) && e.Code == http.StatusUnauthorized) {
return nil, err
}
// If we get a 401, the token doesn't have `events:read_only` scope.
// Disable event polling and fallback to doing a full refresh every interval.
d.eventPollingEnabled = false
} else {
// Event polling tells us changes the Linode API is aware of. Actions issued outside of the Linode API,
// such as issuing a `shutdown` at the VM's console instead of using the API to power off an instance,
Expand Down
6 changes: 3 additions & 3 deletions discovery/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ func NewManager(ctx context.Context, logger *slog.Logger, registerer prometheus.

// Register the metrics.
// We have to do this after setting all options, so that the name of the Manager is set.
if metrics, err := NewManagerMetrics(registerer, mgr.name); err == nil {
mgr.metrics = metrics
} else {
metrics, err := NewManagerMetrics(registerer, mgr.name)
if err != nil {
logger.Error("Failed to create discovery manager metrics", "manager", mgr.name, "err", err)
return nil
}
mgr.metrics = metrics

return mgr
}
Expand Down
21 changes: 10 additions & 11 deletions discovery/moby/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,16 @@ func (d *DockerDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group, er
if len(networks) == 0 {
// Try to lookup shared networks
for {
if containerNetworkMode.IsContainer() {
tmpContainer, exists := allContainers[containerNetworkMode.ConnectedContainer()]
if !exists {
break
}
networks = tmpContainer.NetworkSettings.Networks
containerNetworkMode = container.NetworkMode(tmpContainer.HostConfig.NetworkMode)
if len(networks) > 0 {
break
}
} else {
if !containerNetworkMode.IsContainer() {
break
}
tmpContainer, exists := allContainers[containerNetworkMode.ConnectedContainer()]
if !exists {
break
}
networks = tmpContainer.NetworkSettings.Networks
containerNetworkMode = container.NetworkMode(tmpContainer.HostConfig.NetworkMode)
if len(networks) > 0 {
break
}
}
Expand Down
78 changes: 54 additions & 24 deletions discovery/scaleway/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,30 @@ import (
const (
instanceLabelPrefix = metaLabelPrefix + "instance_"

instanceBootTypeLabel = instanceLabelPrefix + "boot_type"
instanceHostnameLabel = instanceLabelPrefix + "hostname"
instanceIDLabel = instanceLabelPrefix + "id"
instanceImageArchLabel = instanceLabelPrefix + "image_arch"
instanceImageIDLabel = instanceLabelPrefix + "image_id"
instanceImageNameLabel = instanceLabelPrefix + "image_name"
instanceLocationClusterID = instanceLabelPrefix + "location_cluster_id"
instanceLocationHypervisorID = instanceLabelPrefix + "location_hypervisor_id"
instanceLocationNodeID = instanceLabelPrefix + "location_node_id"
instanceNameLabel = instanceLabelPrefix + "name"
instanceOrganizationLabel = instanceLabelPrefix + "organization_id"
instancePrivateIPv4Label = instanceLabelPrefix + "private_ipv4"
instanceProjectLabel = instanceLabelPrefix + "project_id"
instancePublicIPv4Label = instanceLabelPrefix + "public_ipv4"
instancePublicIPv6Label = instanceLabelPrefix + "public_ipv6"
instanceSecurityGroupIDLabel = instanceLabelPrefix + "security_group_id"
instanceSecurityGroupNameLabel = instanceLabelPrefix + "security_group_name"
instanceStateLabel = instanceLabelPrefix + "status"
instanceTagsLabel = instanceLabelPrefix + "tags"
instanceTypeLabel = instanceLabelPrefix + "type"
instanceZoneLabel = instanceLabelPrefix + "zone"
instanceRegionLabel = instanceLabelPrefix + "region"
instanceBootTypeLabel = instanceLabelPrefix + "boot_type"
instanceHostnameLabel = instanceLabelPrefix + "hostname"
instanceIDLabel = instanceLabelPrefix + "id"
instanceImageArchLabel = instanceLabelPrefix + "image_arch"
instanceImageIDLabel = instanceLabelPrefix + "image_id"
instanceImageNameLabel = instanceLabelPrefix + "image_name"
instanceLocationClusterID = instanceLabelPrefix + "location_cluster_id"
instanceLocationHypervisorID = instanceLabelPrefix + "location_hypervisor_id"
instanceLocationNodeID = instanceLabelPrefix + "location_node_id"
instanceNameLabel = instanceLabelPrefix + "name"
instanceOrganizationLabel = instanceLabelPrefix + "organization_id"
instancePrivateIPv4Label = instanceLabelPrefix + "private_ipv4"
instanceProjectLabel = instanceLabelPrefix + "project_id"
instancePublicIPv4Label = instanceLabelPrefix + "public_ipv4"
instancePublicIPv6Label = instanceLabelPrefix + "public_ipv6"
instancePublicIPv4AddressesLabel = instanceLabelPrefix + "public_ipv4_addresses"
instancePublicIPv6AddressesLabel = instanceLabelPrefix + "public_ipv6_addresses"
instanceSecurityGroupIDLabel = instanceLabelPrefix + "security_group_id"
instanceSecurityGroupNameLabel = instanceLabelPrefix + "security_group_name"
instanceStateLabel = instanceLabelPrefix + "status"
instanceTagsLabel = instanceLabelPrefix + "tags"
instanceTypeLabel = instanceLabelPrefix + "type"
instanceZoneLabel = instanceLabelPrefix + "zone"
instanceRegionLabel = instanceLabelPrefix + "region"
)

type instanceDiscovery struct {
Expand Down Expand Up @@ -175,14 +177,42 @@ func (d *instanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group,
}

addr := ""
if len(server.PublicIPs) > 0 {
var ipv4Addresses []string
var ipv6Addresses []string

for _, ip := range server.PublicIPs {
if ip.Family == instance.ServerIPIPFamilyInet {
ipv4Addresses = append(ipv4Addresses, ip.Address.String())
} else if ip.Family == instance.ServerIPIPFamilyInet6 {
ipv6Addresses = append(ipv6Addresses, ip.Address.String())
}
}

if len(ipv6Addresses) > 0 {
labels[instancePublicIPv6AddressesLabel] = model.LabelValue(
separator +
strings.Join(ipv6Addresses, separator) +
separator)
}
if len(ipv4Addresses) > 0 {
labels[instancePublicIPv4AddressesLabel] = model.LabelValue(
separator +
strings.Join(ipv4Addresses, separator) +
separator)
}
}

if server.IPv6 != nil { //nolint:staticcheck
labels[instancePublicIPv6Label] = model.LabelValue(server.IPv6.Address.String()) //nolint:staticcheck
addr = server.IPv6.Address.String() //nolint:staticcheck
}

if server.PublicIP != nil { //nolint:staticcheck
labels[instancePublicIPv4Label] = model.LabelValue(server.PublicIP.Address.String()) //nolint:staticcheck
addr = server.PublicIP.Address.String() //nolint:staticcheck
if server.PublicIP.Family != instance.ServerIPIPFamilyInet6 { //nolint:staticcheck
labels[instancePublicIPv4Label] = model.LabelValue(server.PublicIP.Address.String()) //nolint:staticcheck
}
addr = server.PublicIP.Address.String() //nolint:staticcheck
}

if server.PrivateIP != nil {
Expand Down
Loading
Loading
0