Skip to content

Commit

Permalink
feat: update to prometheus-engine 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSpiritXIII committed Jun 11, 2024
1 parent c91a951 commit c388bbe
Show file tree
Hide file tree
Showing 178 changed files with 24,625 additions and 9,276 deletions.
20 changes: 16 additions & 4 deletions cmd/prometheus/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"syscall"
"time"

"github.com/GoogleCloudPlatform/prometheus-engine/pkg/export"
gcm_export "github.com/GoogleCloudPlatform/prometheus-engine/pkg/export/setup"
"github.com/GoogleCloudPlatform/prometheus-engine/pkg/secrets"
"github.com/alecthomas/kingpin/v2"
Expand Down Expand Up @@ -444,7 +445,12 @@ func main() {
a.Flag("gmp.storage.delete-data-on-start", "[GMP fork experimental flag] If true, all the storage related data (e.g. blocks, lock file, WAL, head chunks) in the --storage.tsdb.path or --storage.agent.path (depending on the mode) will be deleted, right before opening the DB. As a result, all previously collected samples will be uncoverably dropped. Use it in setups where the availability is more important than the persistence between restarts, as replaying data can take time and resources. This flag is especially useful on Kubernetes with ephemeral storage (for consistency between pod vs container restart), remote write use cases that prioritize live data and when you want to auto-recover from the OOM crashloops without changing memory limits for Prometheus (see https://github.com/prometheus/prometheus/issues/13939).").
Default("false").BoolVar(&deleteDataOnStart)

newExporter := gcm_export.FromFlags(a, fmt.Sprintf("prometheus/%s", version.Version))
exporterOpts := gcm_export.DefaultExporterOpts(fmt.Sprintf("prometheus/%s", version.Version))
gcm_export.ExporterOptsFlags(a, &exporterOpts)

haOpts := gcm_export.HAOptions{}
haOpts.Default()
haOpts.SetupFlags(a)

extraArgs, err := gcm_export.ExtraArgs()
if err != nil {
Expand Down Expand Up @@ -871,7 +877,7 @@ func main() {
name: "gcm_export",
reloader: func(cfg *config.Config) error {
// Call in closure to not call Global() before it's initialized below.
return gcm_export.Global().ApplyConfig(cfg)
return gcm_export.Global().ApplyConfig(cfg, nil)
},
},
}
Expand Down Expand Up @@ -939,7 +945,13 @@ func main() {
}
{
ctx, cancel := context.WithCancel(context.Background())
exporter, err := newExporter(ctx, log.With(logger, "component", "gcm_exporter"), prometheus.DefaultRegisterer)
exporterLogger := log.With(logger, "component", "gcm_exporter")
lease, err := haOpts.NewLease(exporterLogger, prometheus.DefaultRegisterer)
if err != nil {
_ = level.Error(exporterLogger).Log("msg", "Unable to setup Cloud Monitoring Exporter lease", "err", err)
os.Exit(1)
}
exporter, err := export.New(ctx, exporterLogger, prometheus.DefaultRegisterer, exporterOpts, lease)
if err != nil {
level.Error(logger).Log("msg", "Unable to init Google Cloud Monitoring exporter", "err", err)
os.Exit(2)
Expand All @@ -951,7 +963,7 @@ func main() {

g.Add(
func() error {
return gcm_export.Global().Run(ctx)
return gcm_export.Global().Run()
},
func(err error) {
cancel()
Expand Down
2 changes: 1 addition & 1 deletion docs/command-line/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The Prometheus monitoring server
| <code class="text-nowrap">--export.debug.metric-prefix</code> | Google Cloud Monitoring metric prefix to use. | `prometheus.googleapis.com` |
| <code class="text-nowrap">--export.debug.disable-auth</code> | Disable authentication (for debugging purposes). | `false` |
| <code class="text-nowrap">--export.debug.batch-size</code> | Maximum number of points to send in one batch to the GCM API. | `200` |
| <code class="text-nowrap">--export.debug.shard-count</code> | Number of shards that track series to send. | `200` |
| <code class="text-nowrap">--export.debug.shard-count</code> | Number of shards that track series to send. | `1024` |
| <code class="text-nowrap">--export.debug.shard-buffer-size</code> | The buffer size for each individual shard. Each element in buffer (queue) consists of sample and hash. | `2048` |
| <code class="text-nowrap">--export.token-url</code> | The request URL to generate token that's needed to ingest metrics to the project | |
| <code class="text-nowrap">--export.token-body</code> | The request Body to generate token that's needed to ingest metrics to the project. | |
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/prometheus/prometheus

go 1.21
go 1.22.3

require (
github.com/Azure/azure-sdk-for-go v65.0.0+incompatible
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1
github.com/Azure/go-autorest/autorest v0.11.29
github.com/Azure/go-autorest/autorest/adal v0.9.23
github.com/GoogleCloudPlatform/prometheus-engine v0.13.0-rc.0
github.com/GoogleCloudPlatform/prometheus-engine v0.13.0-rc.0.0.20240611154736-58f5e6bbcb02
github.com/alecthomas/kingpin/v2 v2.4.0
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9
github.com/aws/aws-sdk-go v1.50.0
Expand Down Expand Up @@ -76,8 +76,8 @@ require (
google.golang.org/protobuf v1.33.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/api v0.30.0
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.29.3
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.120.1
Expand Down Expand Up @@ -195,7 +195,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gotest.tools/v3 v3.0.3 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,8 @@ github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaC
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/GoogleCloudPlatform/prometheus-engine v0.13.0-rc.0 h1:2wg1KPuB3Sasq4jO6ZXHt/qrXfIhDmiab6QVjYTloDw=
github.com/GoogleCloudPlatform/prometheus-engine v0.13.0-rc.0/go.mod h1:wKzPS/rts1HdeXQcUKi8tKcbV5PzJY7be9nYrW7G6/c=
github.com/GoogleCloudPlatform/prometheus-engine v0.13.0-rc.0.0.20240611154736-58f5e6bbcb02 h1:9XdCKakqWrKKfMdX0qWsloZzp45//oHZFX0q78oovbE=
github.com/GoogleCloudPlatform/prometheus-engine v0.13.0-rc.0.0.20240611154736-58f5e6bbcb02/go.mod h1:6hmnv6OSSpBtu5y2/mmN+2PiJ9oBxKGpzCdtplBxywc=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
Expand Down Expand Up @@ -2190,14 +2190,14 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
k8s.io/api v0.29.3 h1:2ORfZ7+bGC3YJqGpV0KSDDEVf8hdGQ6A03/50vj8pmw=
k8s.io/api v0.29.3/go.mod h1:y2yg2NTyHUUkIoTC+phinTnEa3KFM6RZ3szxt014a80=
k8s.io/apimachinery v0.29.3 h1:2tbx+5L7RNvqJjn7RIuIKu9XTsIZ9Z5wX2G22XAa5EU=
k8s.io/apimachinery v0.29.3/go.mod h1:hx/S4V2PNW4OMg3WizRrHutyB5la0iCUbZym+W0EQIU=
k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA=
k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE=
k8s.io/apimachinery v0.30.1 h1:ZQStsEfo4n65yAdlGTfP/uSHMQSoYzU/oeEbkmF7P2U=
k8s.io/apimachinery v0.30.1/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc=
k8s.io/client-go v0.29.3 h1:R/zaZbEAxqComZ9FHeQwOh3Y1ZUs7FaHKZdQtIc2WZg=
k8s.io/client-go v0.29.3/go.mod h1:tkDisCvgPfiRpxGnOORfkljmS+UrW+WtXAy2fTvXJB0=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780=
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
Expand Down
6 changes: 0 additions & 6 deletions tsdb/head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import (
"testing"
"time"

gcm_export "github.com/GoogleCloudPlatform/prometheus-engine/pkg/export"
gcm_exportsetup "github.com/GoogleCloudPlatform/prometheus-engine/pkg/export/setup"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
prom_testutil "github.com/prometheus/client_golang/prometheus/testutil"
Expand All @@ -54,10 +52,6 @@ import (
"github.com/prometheus/prometheus/tsdb/wlog"
)

func init() {
gcm_exportsetup.SetGlobal(gcm_export.NopExporter())
}

func newTestHead(t testing.TB, chunkRange int64, compressWAL, oooEnabled bool) (*Head, *wlog.WL) {
dir := t.TempDir()
wal, err := wlog.NewSize(nil, nil, filepath.Join(dir, "wal"), 32768, compressWAL)
Expand Down
Loading

0 comments on commit c388bbe

Please sign in to comment.