From 231361258a2af6747591baa76cf20a8e1d265db1 Mon Sep 17 00:00:00 2001 From: Anders Swanson Date: Fri, 28 Feb 2025 11:52:42 -0800 Subject: [PATCH 1/3] Package updates Signed-off-by: Anders Swanson --- README.md | 174 ++--------------------------------- alertlog/alertlog.go | 30 +++--- changelog.md | 170 ++++++++++++++++++++++++++++++++++ collector/collector.go | 107 ++++++++++----------- collector/default_metrics.go | 7 +- collector/metrics.go | 11 +-- collector/types.go | 4 +- go.mod | 18 ++-- go.sum | 19 ++++ main.go | 44 ++++----- vault/vault.go | 13 ++- 11 files changed, 308 insertions(+), 289 deletions(-) create mode 100644 changelog.md diff --git a/README.md b/README.md index 55e6653..1d59e7a 100644 --- a/README.md +++ b/README.md @@ -25,173 +25,17 @@ Contributions are welcome - please see [contributing](CONTRIBUTING.md). - [Monitoring Transactional Event Queues](#monitoring-transactional-event-queues) - [Developer notes](#developer-notes) -## Release Notes +## Releases -### Version 1.5.4, February 27, 2025 +| Release | Date | Changelog | +|---------|----------------------|-----------------------------------------------------------------| +| 1.5.4 | March 3rd, 2025 | [1.5.4 Changelog](./changelog.md#version-154-march-3-2025) | +| 1.5.3 | January 28th, 2025 | [1.5.3 Changelog](./changelog.md#version-153-january-28-2025) | +| 1.5.2 | December 2nd, 2024 | [1.5.2 Changelog](./changelog.md#version-152-december-2-2024) | +| 1.5.1 | October 28th, 2024 | [1.5.1 Changelog](./changelog.md#version-151-october-28-2024) | +| 1.5.0 | September 26th, 2024 | [1.5.0 Changelog](./changelog.md#version-150-september-26-2024) | -Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues -with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release. - -- Fix malloc error (#177) -- Add support for additional admin roles, exapnding list of options for `DB_ROILE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180) -- Updated some third-party dependencies. - -Thank you to the following people for their suggestions and contributions: - -- [@Jman1993](https://github.com/Jman1993) -- [@oey](https://github.com/oey) -- [@jlembeck06](https://github.com/jlembeck06) -- [@Jman1993](https://github.com/Jman1993) -- [@PeterP55P](https://github.com/PeterP55P) -- [@rlagyu0](https://github.com/rlagyu0) - -In this release, we also continued some minor code refactoring. - -### Version 1.5.3, January 28, 2025 - -*Known issue*: This release has a known issue that results in the error message `malloc(): unsorted double linked list corrupted`. -We recommend staying on 1.5.2 until a new release with a fix is available. We hope to have a fix by early March. - -Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues -with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release. - -This release includes the following changes: - -- Fix over-zealous supression of errors when `ignorezeroresult = true` (#168). -- When `scrapeinterval` is set, do first scrape immediately, not after the interval (#166). -- Updated some third-party dependencies. - -Thank you to the following people for their suggestions and contributions: - -- [@redelang](https://github.com/redelang) - -In this release, we also started some minor code refactoring. - -### Version 1.5.2, December 2, 2024 - -This release includes the following changes: - -- Update the metric defintion for tablespace usage to report more accurate temp space usage. -- Revert InstantClient to 21c version due to ADB connectivity issue. -- Update documentation to explain how to obtain credentials from a wallet. -- Fix race condition on err variable in scrape() func (by @valrusu). -- Updated some third-party dependencies. - -Thank you to the following people for their suggestions and contributions: - -- [@aureliocirella](https://github.com/aureliocirella) -- [@mitoeth](https://github.com/mitoeth) -- [@valrusu](https://github.com/valrusu) - -### Version 1.5.1, October 28, 2024 - -This release includes the following changes: - -- Added support for using the `TNS_ADMIN` environment variable, which fixes an issue when connecting to Autonomous Database instances using TNS name. -- Updated InstantClient to 23ai version for amd64 and latest available 19.24 version for arm64. -- Fixed an issue with wrong `LD_LIBRARY_PATH` on some platforms. (#136) -- Added documentation and an example of using the `scrapeinterval` setting to change the interval at which a certain metric is colected. -- Added notes to documentation for extra security parameters needed when using a wallet with Podman. -- Updated some third-party dependencies. - -### Version 1.5.0, September 26, 2024 - -This release includes the following changes: - -- Support for running the exporter on ARM processors (darwin and linux). -- Updated some third-party dependencies. -- Updated the "test/demo environment" to use newer version of Oracle Database (23.5.0.24.07) and faster startup. - -### Version 1.4.0, September 4, 2024 - -This release includes the following changes: - -- Allow multiple custom metrics definition files. -- Allow query timeout per-metric. -- Allow scrape interval per-metric. -- Updated some third-party dependencies. - -### Version 1.3.1, July 22, 2024 - -This release includes the following changes: - -- Alert logs can be disabled by setting parameter `log.disable` to `1`. -- Alert log exporter will stop if it gets three consecutive failures. -- Updated the list of required permissions. -- Updated the TxEventQ sample dashboard. -- Updated some third-party dependencies. - -Thank you to the following people for their suggestions and contributions: - -- [@tux-jochen](https://github.com/tux-jochen) - -### Version 1.3.0, June 7, 2024 - -This release includes the following changes: - -- Alert logs can be exported for collection by a log reader like Promtail or FluentBit. Default - output to `/log/alert.log` in JSON format. -- Provide ability to connect as SYSDBA or SYSOPER by setting DB_ROLE. -- New default metric is added to report the type of database connected to (CDB or PDB). -- New default metrics are added for cache hit ratios. -- Default metrics updated to suppress spurious warnings in log. -- Wait class metric updated to use a better query. -- The sample dashboard is updated to include new metrics. -- Fixed a bug which prevented periodic freeing of memory. -- Set CLIENT_INFO to a meaningful value. -- Update Go toolchain to 1.22.4. -- Updated some third-party dependencies. - -Thank you to the following people for their suggestions and contributions: - -- [@pioro](https://github.com/pioro) -- [@savoir81](https://github.com/savoir81) - -### Version 1.2.1, April 16, 2024 - -This release includes the following changes: - -- Accept max idle and open connections settings as parameters. -- Updated some third-party dependencies. - -### Version 1.2.0, January 17, 2024 - -This release includes the following changes: - -- Introduced a new feature to periodically restart the process if requested. -- Introduced a new feature to periodically attempt to free OS memory if requested. -- Updated some third-party dependencies. - -### Version 1.1.1, November 28, 2023 - -This release just updates some third-party dependencies. - -### Version 1.1, October 27, 2023 - -This release includes the following changes: - -- The query for the standard metric `wait_class` has been updated so that it will work in both container databases - and pluggable databases, including in Oracle Autonomous Database instances. Note that this query will not return - any data unless the database instance is under load. -- Support for reading the database password from OCI Vault has been added (see [details](#using-oci-vault)) -- Log messages have been improved -- Some dependencies have been updated - -### Version 1.0, September 13, 2023 - -The first production release, v1.0, includes the following features: - -- A number of [standard metrics](#standard-metrics) are exposed, -- Users can define [custom metrics](#custom-metrics), -- Oracle regularly reviews third-party licenses and scans the code and images, including transitive/recursive dependencies for issues, -- Connection to Oracle can be a basic connection or use an Oracle Wallet and TLS - connection to Oracle Autonomous Database is supported, -- Metrics for Oracle Transactional Event Queues are also supported, -- A Grafana dashboard is provided for Transactional Event Queues, and -- A pre-built container image is provided, based on Oracle Linux, and optimized for size and security. - -Note that this exporter uses a different Oracle Database driver which in turn uses code directly written by Oracle to access the database. This driver does require an Oracle client. In this initial release, the client is bundled into the container image, however we intend to make that optional in order to minimize the image size. - -The interfaces for this version have been kept as close as possible to those of earlier alpha releases in this repository to assist with migration. However, it should be expected that there may be breaking changes in future releases. +For releases notes on older releases, see the [Changelog](./changelog.md) ## Roadmap diff --git a/alertlog/alertlog.go b/alertlog/alertlog.go index 343c661..d4b97f7 100644 --- a/alertlog/alertlog.go +++ b/alertlog/alertlog.go @@ -1,4 +1,4 @@ -// Copyright (c) 2024, Oracle and/or its affiliates. +// Copyright (c) 2024, 2025, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.package vault package alertlog @@ -9,11 +9,9 @@ import ( "errors" "fmt" "io" + "log/slog" "os" "strings" - - "github.com/go-kit/log" - "github.com/go-kit/log/level" ) type LogRecord struct { @@ -25,10 +23,10 @@ type LogRecord struct { var queryFailures int = 0 -func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { +func UpdateLog(logDestination string, logger *slog.Logger, db *sql.DB) { if queryFailures == 3 { - level.Info(logger).Log("msg", "Failed to query the alert log three consecutive times, so will not try any more") + logger.Info("Failed to query the alert log three consecutive times, so will not try any more") queryFailures++ return } @@ -39,10 +37,10 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { // check if the log file exists, and if not, create it if _, err := os.Stat(logDestination); errors.Is(err, os.ErrNotExist) { - level.Info(logger).Log("msg", "Log destination file does not exist, will try to create it: "+logDestination) + logger.Info("Log destination file does not exist, will try to create it: " + logDestination) f, e := os.Create(logDestination) if e != nil { - level.Error(logger).Log("msg", "Failed to create the log file: "+logDestination) + logger.Error("Failed to create the log file: " + logDestination) return } f.Close() @@ -52,7 +50,7 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { file, err := os.Open(logDestination) if err != nil { - level.Error(logger).Log("msg", "Could not open the alert log destination file: "+logDestination) + logger.Error("Could not open the alert log destination file: " + logDestination) return } @@ -101,7 +99,7 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { var lastLogRecord LogRecord err = json.Unmarshal([]byte(line), &lastLogRecord) if err != nil { - level.Error(logger).Log("msg", "Could not parse last line of log file") + logger.Error("Could not parse last line of log file") return } @@ -112,7 +110,7 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { rows, err := db.Query(stmt) if err != nil { - level.Error(logger).Log("msg", "Error querying the alert logs") + logger.Error("Error querying the alert logs") queryFailures++ return } @@ -121,7 +119,7 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { // write them to the file outfile, err := os.OpenFile(logDestination, os.O_APPEND|os.O_WRONLY, 0600) if err != nil { - level.Error(logger).Log("msg", "Could not open log file for writing: "+logDestination) + logger.Error("Could not open log file for writing: " + logDestination) return } defer outfile.Close() @@ -130,7 +128,7 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { for rows.Next() { var newRecord LogRecord if err := rows.Scan(&newRecord.Timestamp, &newRecord.ModuleId, &newRecord.ECID, &newRecord.Message); err != nil { - level.Error(logger).Log("msg", "Error reading a row from the alert logs") + logger.Error("Error reading a row from the alert logs") return } @@ -139,18 +137,18 @@ func UpdateLog(logDestination string, logger log.Logger, db *sql.DB) { jsonLogRecord, err := json.Marshal(newRecord) if err != nil { - level.Error(logger).Log("msg", "Error marshalling alert log record") + logger.Error("Error marshalling alert log record") return } if _, err = outfile.WriteString(string(jsonLogRecord) + "\n"); err != nil { - level.Error(logger).Log("msg", "Could not write to log file: "+logDestination) + logger.Error("Could not write to log file: " + logDestination) return } } if err = rows.Err(); err != nil { - level.Error(logger).Log("msg", "Error querying the alert logs") + logger.Error("Error querying the alert logs") queryFailures++ } } diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..0fefc93 --- /dev/null +++ b/changelog.md @@ -0,0 +1,170 @@ +## Release Notes + +### Version 1.5.4, March 3, 2025 + +Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues +with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release. + +- Fix malloc error (#177) +- Fix Multiple custom metrics files overwrite one another (#179) +- Replace go-kit/log with log/slog, due to upstream changes in prometheus/common +- Add support for additional admin roles, exapnding list of options for `DB_ROILE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180) +- Updated some third-party dependencies. + +Thank you to the following people for their suggestions and contributions: + +- [@Jman1993](https://github.com/Jman1993) +- [@oey](https://github.com/oey) +- [@jlembeck06](https://github.com/jlembeck06) +- [@Jman1993](https://github.com/Jman1993) +- [@PeterP55P](https://github.com/PeterP55P) +- [@rlagyu0](https://github.com/rlagyu0) +- [@Sycri](https://github.com/Sycri) + +In this release, we also continued some minor code refactoring. + +### Version 1.5.3, January 28, 2025 + +*Known issue*: This release has a known issue that results in the error message `malloc(): unsorted double linked list corrupted`. +We recommend staying on 1.5.2 until a new release with a fix is available. We hope to have a fix by early March. + +Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues +with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release. + +This release includes the following changes: + +- Fix over-zealous supression of errors when `ignorezeroresult = true` (#168). +- When `scrapeinterval` is set, do first scrape immediately, not after the interval (#166). +- Updated some third-party dependencies. + +Thank you to the following people for their suggestions and contributions: + +- [@redelang](https://github.com/redelang) + +In this release, we also started some minor code refactoring. + +### Version 1.5.2, December 2, 2024 + +This release includes the following changes: + +- Update the metric defintion for tablespace usage to report more accurate temp space usage. +- Revert InstantClient to 21c version due to ADB connectivity issue. +- Update documentation to explain how to obtain credentials from a wallet. +- Fix race condition on err variable in scrape() func (by @valrusu). +- Updated some third-party dependencies. + +Thank you to the following people for their suggestions and contributions: + +- [@aureliocirella](https://github.com/aureliocirella) +- [@mitoeth](https://github.com/mitoeth) +- [@valrusu](https://github.com/valrusu) + +### Version 1.5.1, October 28, 2024 + +This release includes the following changes: + +- Added support for using the `TNS_ADMIN` environment variable, which fixes an issue when connecting to Autonomous Database instances using TNS name. +- Updated InstantClient to 23ai version for amd64 and latest available 19.24 version for arm64. +- Fixed an issue with wrong `LD_LIBRARY_PATH` on some platforms. (#136) +- Added documentation and an example of using the `scrapeinterval` setting to change the interval at which a certain metric is colected. +- Added notes to documentation for extra security parameters needed when using a wallet with Podman. +- Updated some third-party dependencies. + +### Version 1.5.0, September 26, 2024 + +This release includes the following changes: + +- Support for running the exporter on ARM processors (darwin and linux). +- Updated some third-party dependencies. +- Updated the "test/demo environment" to use newer version of Oracle Database (23.5.0.24.07) and faster startup. + +### Version 1.4.0, September 4, 2024 + +This release includes the following changes: + +- Allow multiple custom metrics definition files. +- Allow query timeout per-metric. +- Allow scrape interval per-metric. +- Updated some third-party dependencies. + +### Version 1.3.1, July 22, 2024 + +This release includes the following changes: + +- Alert logs can be disabled by setting parameter `log.disable` to `1`. +- Alert log exporter will stop if it gets three consecutive failures. +- Updated the list of required permissions. +- Updated the TxEventQ sample dashboard. +- Updated some third-party dependencies. + +Thank you to the following people for their suggestions and contributions: + +- [@tux-jochen](https://github.com/tux-jochen) + +### Version 1.3.0, June 7, 2024 + +This release includes the following changes: + +- Alert logs can be exported for collection by a log reader like Promtail or FluentBit. Default + output to `/log/alert.log` in JSON format. +- Provide ability to connect as SYSDBA or SYSOPER by setting DB_ROLE. +- New default metric is added to report the type of database connected to (CDB or PDB). +- New default metrics are added for cache hit ratios. +- Default metrics updated to suppress spurious warnings in log. +- Wait class metric updated to use a better query. +- The sample dashboard is updated to include new metrics. +- Fixed a bug which prevented periodic freeing of memory. +- Set CLIENT_INFO to a meaningful value. +- Update Go toolchain to 1.22.4. +- Updated some third-party dependencies. + +Thank you to the following people for their suggestions and contributions: + +- [@pioro](https://github.com/pioro) +- [@savoir81](https://github.com/savoir81) + +### Version 1.2.1, April 16, 2024 + +This release includes the following changes: + +- Accept max idle and open connections settings as parameters. +- Updated some third-party dependencies. + +### Version 1.2.0, January 17, 2024 + +This release includes the following changes: + +- Introduced a new feature to periodically restart the process if requested. +- Introduced a new feature to periodically attempt to free OS memory if requested. +- Updated some third-party dependencies. + +### Version 1.1.1, November 28, 2023 + +This release just updates some third-party dependencies. + +### Version 1.1, October 27, 2023 + +This release includes the following changes: + +- The query for the standard metric `wait_class` has been updated so that it will work in both container databases + and pluggable databases, including in Oracle Autonomous Database instances. Note that this query will not return + any data unless the database instance is under load. +- Support for reading the database password from OCI Vault has been added (see [details](#using-oci-vault)) +- Log messages have been improved +- Some dependencies have been updated + +### Version 1.0, September 13, 2023 + +The first production release, v1.0, includes the following features: + +- A number of [standard metrics](#standard-metrics) are exposed, +- Users can define [custom metrics](#custom-metrics), +- Oracle regularly reviews third-party licenses and scans the code and images, including transitive/recursive dependencies for issues, +- Connection to Oracle can be a basic connection or use an Oracle Wallet and TLS - connection to Oracle Autonomous Database is supported, +- Metrics for Oracle Transactional Event Queues are also supported, +- A Grafana dashboard is provided for Transactional Event Queues, and +- A pre-built container image is provided, based on Oracle Linux, and optimized for size and security. + +Note that this exporter uses a different Oracle Database driver which in turn uses code directly written by Oracle to access the database. This driver does require an Oracle client. In this initial release, the client is bundled into the container image, however we intend to make that optional in order to minimize the image size. + +The interfaces for this version have been kept as close as possible to those of earlier alpha releases in this repository to assist with migration. However, it should be expected that there may be breaking changes in future releases. \ No newline at end of file diff --git a/collector/collector.go b/collector/collector.go index da59202..4747232 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -13,6 +13,7 @@ import ( "fmt" "hash" "io" + "log/slog" "os" "strconv" "strings" @@ -20,8 +21,6 @@ import ( "time" "github.com/BurntSushi/toml" - "github.com/go-kit/log" - "github.com/go-kit/log/level" "github.com/godror/godror" "github.com/godror/godror/dsn" "github.com/prometheus/client_golang/prometheus" @@ -50,7 +49,7 @@ func maskDsn(dsn string) string { } // NewExporter creates a new Exporter instance -func NewExporter(logger log.Logger, cfg *Config) (*Exporter, error) { +func NewExporter(logger *slog.Logger, cfg *Config) (*Exporter, error) { e := &Exporter{ mu: &sync.Mutex{}, user: cfg.User, @@ -217,18 +216,18 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { begun := time.Now() if connectionError := e.db.Ping(); connectionError != nil { - level.Debug(e.logger).Log("msg", "error = "+connectionError.Error()) + e.logger.Debug("error = " + connectionError.Error()) if strings.Contains(connectionError.Error(), "sql: database is closed") { - level.Info(e.logger).Log("msg", "Reconnecting to DB") + e.logger.Info("Reconnecting to DB") connectionError = e.connect() if connectionError != nil { - level.Error(e.logger).Log("msg", "Error reconnecting to DB", connectionError) + e.logger.Error("Error reconnecting to DB", connectionError) } } } if pingError := e.db.Ping(); pingError != nil { - level.Error(e.logger).Log("msg", "Error pinging oracle", + e.logger.Error("Error pinging oracle", "error", pingError) e.up.Set(0) e.error.Set(1) @@ -238,7 +237,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { e.dbtypeGauge.Set(float64(e.dbtype)) - level.Debug(e.logger).Log("msg", "Successfully pinged Oracle database: "+maskDsn(e.connectString)) + e.logger.Debug("Successfully pinged Oracle database: " + maskDsn(e.connectString)) e.up.Set(1) if e.checkIfMetricsChanged() { @@ -249,7 +248,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { metric := metric //https://golang.org/doc/faq#closures_and_goroutines go func() { - level.Debug(e.logger).Log("msg", "About to scrape metric", + e.logger.Debug("About to scrape metric", "Context", metric.Context, "MetricsDesc", fmt.Sprint(metric.MetricsDesc), "MetricsType", fmt.Sprint(metric.MetricsType), @@ -261,13 +260,13 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { if len(metric.Request) == 0 { errChan <- errors.New("scrape request not found") - level.Error(e.logger).Log("msg", "Error scraping for "+fmt.Sprint(metric.MetricsDesc)+". Did you forget to define request in your toml file?") + e.logger.Error("Error scraping for " + fmt.Sprint(metric.MetricsDesc) + ". Did you forget to define request in your toml file?") return } if len(metric.MetricsDesc) == 0 { errChan <- errors.New("metricsdesc not found") - level.Error(e.logger).Log("msg", "Error scraping for query"+fmt.Sprint(metric.Request)+". Did you forget to define metricsdesc in your toml file?") + e.logger.Error("Error scraping for query" + fmt.Sprint(metric.Request) + ". Did you forget to define metricsdesc in your toml file?") return } @@ -276,7 +275,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { _, ok := metric.MetricsBuckets[column] if !ok { errChan <- errors.New("metricsbuckets not found") - level.Error(e.logger).Log("msg", "Unable to find MetricsBuckets configuration key for metric. (metric="+column+")") + e.logger.Error("Unable to find MetricsBuckets configuration key for metric. (metric=" + column + ")") return } } @@ -288,7 +287,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { errChan <- scrapeError if scrapeError != nil { if shouldLogScrapeError(scrapeError, metric.IgnoreZeroResult) { - level.Error(e.logger).Log("msg", "Error scraping metric", + e.logger.Error("Error scraping metric", "Context", metric.Context, "MetricsDesc", fmt.Sprint(metric.MetricsDesc), "time", time.Since(scrapeStart), @@ -296,7 +295,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { } e.scrapeErrors.WithLabelValues(metric.Context).Inc() } else { - level.Debug(e.logger).Log("msg", "Successfully scraped metric", + e.logger.Debug("Successfully scraped metric", "Context", metric.Context, "MetricDesc", fmt.Sprint(metric.MetricsDesc), "time", time.Since(scrapeStart)) @@ -323,18 +322,18 @@ func (e *Exporter) afterScrape(begun time.Time, countMetrics int, errChan chan e } func (e *Exporter) connect() error { - level.Debug(e.logger).Log("msg", "Launching connection to "+maskDsn(e.connectString)) + e.logger.Debug("Launching connection to " + maskDsn(e.connectString)) var P godror.ConnectionParams // If password is not specified, externalAuth will be true and we'll ignore user input e.externalAuth = e.password == "" - level.Debug(e.logger).Log("external authentication set to ", e.externalAuth) + e.logger.Debug("external authentication set to ", e.externalAuth) msg := "Using Username/Password Authentication." if e.externalAuth { msg = "Database Password not specified; will attempt to use external authentication (ignoring user input)." e.user = "" } - level.Info(e.logger).Log("msg", msg) + e.logger.Info(msg) externalAuth := sql.NullBool{ Bool: e.externalAuth, Valid: true, @@ -342,15 +341,15 @@ func (e *Exporter) connect() error { P.Username, P.Password, P.ConnectString, P.ExternalAuth = e.user, godror.NewPassword(e.password), e.connectString, externalAuth if e.config.PoolIncrement > 0 { - level.Debug(e.logger).Log("msg", "set pool increment to ", e.config.PoolIncrement) + e.logger.Debug("set pool increment to ", e.config.PoolIncrement) P.PoolParams.SessionIncrement = e.config.PoolIncrement } if e.config.PoolMaxConnections > 0 { - level.Debug(e.logger).Log("msg", "set pool max connections to ", e.config.PoolMaxConnections) + e.logger.Debug("set pool max connections to ", e.config.PoolMaxConnections) P.PoolParams.MaxSessions = e.config.PoolMaxConnections } if e.config.PoolMinConnections > 0 { - level.Debug(e.logger).Log("msg", "set pool min connections to ", e.config.PoolMinConnections) + e.logger.Debug("set pool min connections to ", e.config.PoolMinConnections) P.PoolParams.MinSessions = e.config.PoolMinConnections } @@ -378,37 +377,37 @@ func (e *Exporter) connect() error { P.AdminRole = dsn.NoRole } - level.Debug(e.logger).Log("msg", "connection properties: "+fmt.Sprint(P)) + e.logger.Debug("connection properties: " + fmt.Sprint(P)) // note that this just configures the connection, it does not actually connect until later // when we call db.Ping() db := sql.OpenDB(godror.NewConnector(P)) - level.Debug(e.logger).Log("msg", "set max idle connections to ", e.config.MaxIdleConns) + e.logger.Debug("set max idle connections to ", e.config.MaxIdleConns) db.SetMaxIdleConns(e.config.MaxIdleConns) - level.Debug(e.logger).Log("msg", "set max open connections to ", e.config.MaxOpenConns) + e.logger.Debug("set max open connections to ", e.config.MaxOpenConns) db.SetMaxOpenConns(e.config.MaxOpenConns) db.SetConnMaxLifetime(0) - level.Debug(e.logger).Log("msg", "Successfully configured connection to "+maskDsn(e.connectString)) + e.logger.Debug("Successfully configured connection to " + maskDsn(e.connectString)) e.db = db if _, err := db.Exec(` begin dbms_application_info.set_client_info('oracledb_exporter'); end;`); err != nil { - level.Info(e.logger).Log("msg", "Could not set CLIENT_INFO.") + e.logger.Info("Could not set CLIENT_INFO.") } var result int if err := db.QueryRow("select sys_context('USERENV', 'CON_ID') from dual").Scan(&result); err != nil { - level.Info(e.logger).Log("msg", "dbtype err ="+string(err.Error())) + e.logger.Info("dbtype err =" + string(err.Error())) } e.dbtype = result var sysdba string if err := db.QueryRow("select sys_context('USERENV', 'ISDBA') from dual").Scan(&sysdba); err != nil { - level.Info(e.logger).Log("msg", "got error checking my database role") + e.logger.Info("got error checking my database role") } - level.Info(e.logger).Log("msg", "Connected as SYSDBA? "+sysdba) + e.logger.Info("Connected as SYSDBA? " + sysdba) return nil } @@ -423,15 +422,15 @@ func (e *Exporter) checkIfMetricsChanged() bool { if len(_customMetrics) == 0 { continue } - level.Debug(e.logger).Log("msg", "Checking modifications in following metrics definition file:"+_customMetrics) + e.logger.Debug("Checking modifications in following metrics definition file:" + _customMetrics) h := sha256.New() if err := hashFile(h, _customMetrics); err != nil { - level.Error(e.logger).Log("msg", "Unable to get file hash", "error", err) + e.logger.Error("Unable to get file hash", "error", err) return false } // If any of files has been changed reload metrics if !bytes.Equal(hashMap[i], h.Sum(nil)) { - level.Info(e.logger).Log("msg", _customMetrics+" has been changed. Reloading metrics...") + e.logger.Info(_customMetrics + " has been changed. Reloading metrics...") hashMap[i] = h.Sum(nil) return true } @@ -464,21 +463,21 @@ func (e *Exporter) reloadMetrics() { for _, _customMetrics := range strings.Split(e.config.CustomMetrics, ",") { metrics := &Metrics{} if _, err := toml.DecodeFile(_customMetrics, metrics); err != nil { - level.Error(e.logger).Log(err) + e.logger.Error("failed to load custom metrics", err) panic(errors.New("Error while loading " + _customMetrics)) } else { - level.Info(e.logger).Log("msg", "Successfully loaded custom metrics from "+_customMetrics) + e.logger.Info("Successfully loaded custom metrics from " + _customMetrics) } e.metricsToScrape.Metric = append(e.metricsToScrape.Metric, metrics.Metric...) } } else { - level.Debug(e.logger).Log("msg", "No custom metrics defined.") + e.logger.Debug("No custom metrics defined.") } } // ScrapeMetric is an interface method to call scrapeGenericValues using Metric struct values func (e *Exporter) ScrapeMetric(db *sql.DB, ch chan<- prometheus.Metric, m Metric, tick *time.Time) error { - level.Debug(e.logger).Log("msg", "Calling function ScrapeGenericValues()") + e.logger.Debug("Calling function ScrapeGenericValues()") if e.isScrapeMetric(tick, m) { queryTimeout := e.getQueryTimeout(m) return e.scrapeGenericValues(db, ch, m.Context, m.Labels, m.MetricsDesc, @@ -504,11 +503,11 @@ func (e *Exporter) scrapeGenericValues(db *sql.DB, ch chan<- prometheus.Metric, value, err := strconv.ParseFloat(strings.TrimSpace(row[metric]), 64) // If not a float, skip current metric if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert current value to float (metric="+metric+ - ",metricHelp="+metricHelp+",value=<"+row[metric]+">)") + e.logger.Error("Unable to convert current value to float (metric=" + metric + + ",metricHelp=" + metricHelp + ",value=<" + row[metric] + ">)") continue } - level.Debug(e.logger).Log("msg", "Query result", + e.logger.Debug("Query result", "value", value) // If metric do not use a field content in metric's name if strings.Compare(fieldToAppend, "") == 0 { @@ -520,21 +519,21 @@ func (e *Exporter) scrapeGenericValues(db *sql.DB, ch chan<- prometheus.Metric, if metricsType[strings.ToLower(metric)] == "histogram" { count, err := strconv.ParseUint(strings.TrimSpace(row["count"]), 10, 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert count value to int (metric="+metric+ - ",metricHelp="+metricHelp+",value=<"+row["count"]+">)") + e.logger.Error("Unable to convert count value to int (metric=" + metric + + ",metricHelp=" + metricHelp + ",value=<" + row["count"] + ">)") continue } buckets := make(map[float64]uint64) for field, le := range metricsBuckets[metric] { lelimit, err := strconv.ParseFloat(strings.TrimSpace(le), 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert bucket limit value to float (metric="+metric+ - ",metricHelp="+metricHelp+",bucketlimit=<"+le+">)") + e.logger.Error("Unable to convert bucket limit value to float (metric=" + metric + + ",metricHelp=" + metricHelp + ",bucketlimit=<" + le + ">)") continue } counter, err := strconv.ParseUint(strings.TrimSpace(row[field]), 10, 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert ", field, " value to int (metric="+metric+ + e.logger.Error("Unable to convert ", field, " value to int (metric="+metric+ ",metricHelp="+metricHelp+",value=<"+row[field]+">)") continue } @@ -554,21 +553,21 @@ func (e *Exporter) scrapeGenericValues(db *sql.DB, ch chan<- prometheus.Metric, if metricsType[strings.ToLower(metric)] == "histogram" { count, err := strconv.ParseUint(strings.TrimSpace(row["count"]), 10, 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert count value to int (metric="+metric+ - ",metricHelp="+metricHelp+",value=<"+row["count"]+">)") + e.logger.Error("Unable to convert count value to int (metric=" + metric + + ",metricHelp=" + metricHelp + ",value=<" + row["count"] + ">)") continue } buckets := make(map[float64]uint64) for field, le := range metricsBuckets[metric] { lelimit, err := strconv.ParseFloat(strings.TrimSpace(le), 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert bucket limit value to float (metric="+metric+ - ",metricHelp="+metricHelp+",bucketlimit=<"+le+">)") + e.logger.Error("Unable to convert bucket limit value to float (metric=" + metric + + ",metricHelp=" + metricHelp + ",bucketlimit=<" + le + ">)") continue } counter, err := strconv.ParseUint(strings.TrimSpace(row[field]), 10, 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert ", field, " value to int (metric="+metric+ + e.logger.Error("Unable to convert ", field, " value to int (metric="+metric+ ",metricHelp="+metricHelp+",value=<"+row[field]+">)") continue } @@ -583,9 +582,9 @@ func (e *Exporter) scrapeGenericValues(db *sql.DB, ch chan<- prometheus.Metric, } return nil } - level.Debug(e.logger).Log("msg", "Calling function GeneratePrometheusMetrics()") + e.logger.Debug("Calling function GeneratePrometheusMetrics()") err := e.generatePrometheusMetrics(db, genericParser, request, queryTimeout) - level.Debug(e.logger).Log("msg", "ScrapeGenericValues() - metricsCount: "+strconv.Itoa(metricsCount)) + e.logger.Debug("ScrapeGenericValues() - metricsCount: " + strconv.Itoa(metricsCount)) if err != nil { return err } @@ -670,11 +669,3 @@ func cleanName(s string) string { s = strings.ToLower(s) return s } - -func (e *Exporter) logError(s string) { - _ = level.Error(e.logger).Log(s) -} - -func (e *Exporter) logDebug(s string) { - _ = level.Debug(e.logger).Log(s) -} diff --git a/collector/default_metrics.go b/collector/default_metrics.go index bc83626..af087af 100644 --- a/collector/default_metrics.go +++ b/collector/default_metrics.go @@ -1,4 +1,4 @@ -// Copyright (c) 2021, 2024, Oracle and/or its affiliates. +// Copyright (c) 2021, 2025, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. // Portions Copyright (c) 2016 Seth Miller @@ -11,7 +11,6 @@ import ( "path/filepath" "github.com/BurntSushi/toml" - "github.com/go-kit/log/level" ) //go:embed default_metrics.toml @@ -22,14 +21,14 @@ func (e *Exporter) DefaultMetrics() Metrics { var metricsToScrape Metrics if e.config.DefaultMetricsFile != "" { if _, err := toml.DecodeFile(filepath.Clean(e.config.DefaultMetricsFile), &metricsToScrape); err != nil { - level.Error(e.logger).Log("msg", fmt.Sprintf("there was an issue while loading specified default metrics file at: "+e.config.DefaultMetricsFile+", proceeding to run with default metrics."), + e.logger.Error(fmt.Sprintf("there was an issue while loading specified default metrics file at: "+e.config.DefaultMetricsFile+", proceeding to run with default metrics."), "error", err) } return metricsToScrape } if _, err := toml.Decode(defaultMetricsToml, &metricsToScrape); err != nil { - level.Error(e.logger).Log(err) + e.logger.Error("failed to load default metrics", err) panic(errors.New("Error while loading " + defaultMetricsToml)) } return metricsToScrape diff --git a/collector/metrics.go b/collector/metrics.go index e20ddd1..f6d98c8 100644 --- a/collector/metrics.go +++ b/collector/metrics.go @@ -1,10 +1,9 @@ -// Copyright (c) 2024, Oracle and/or its affiliates. +// Copyright (c) 2024, 2025, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl package collector import ( - "github.com/go-kit/log/level" "strconv" "time" ) @@ -31,7 +30,7 @@ func (e *Exporter) getScrapeInterval(context, scrapeInterval string) (time.Durat if len(scrapeInterval) > 0 { si, err := time.ParseDuration(scrapeInterval) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert scrapeinterval to duration (metric="+context+")") + e.logger.Error("Unable to convert scrapeinterval to duration (metric=" + context + ")") return 0, false } return si, true @@ -43,7 +42,7 @@ func (e *Exporter) getQueryTimeout(metric Metric) time.Duration { if len(metric.QueryTimeout) > 0 { qt, err := time.ParseDuration(metric.QueryTimeout) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert querytimeout to duration (metric="+metric.Context+")") + e.logger.Error("Unable to convert querytimeout to duration (metric=" + metric.Context + ")") return time.Duration(e.config.QueryTimeout) * time.Second } return qt @@ -58,8 +57,8 @@ func (e *Exporter) parseFloat(metric, metricHelp string, row map[string]string) } valueFloat, err := strconv.ParseFloat(value, 64) if err != nil { - level.Error(e.logger).Log("msg", "Unable to convert current value to float (metric="+metric+ - ",metricHelp="+metricHelp+",value=<"+row[metric]+">)") + e.logger.Error("Unable to convert current value to float (metric=" + metric + + ",metricHelp=" + metricHelp + ",value=<" + row[metric] + ">)") return -1, false } return valueFloat, true diff --git a/collector/types.go b/collector/types.go index 8c8428b..7a04fb9 100644 --- a/collector/types.go +++ b/collector/types.go @@ -4,9 +4,9 @@ package collector import ( "database/sql" - "github.com/go-kit/log" "github.com/godror/godror/dsn" "github.com/prometheus/client_golang/prometheus" + "log/slog" "sync" "time" ) @@ -30,7 +30,7 @@ type Exporter struct { dbtype int dbtypeGauge prometheus.Gauge db *sql.DB - logger log.Logger + logger *slog.Logger lastTick *time.Time } diff --git a/go.mod b/go.mod index d431d48..ebcc4e0 100644 --- a/go.mod +++ b/go.mod @@ -9,10 +9,10 @@ require ( github.com/alecthomas/kingpin/v2 v2.4.0 github.com/go-kit/log v0.2.1 github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090 - github.com/oracle/oci-go-sdk/v65 v65.81.1 - github.com/prometheus/client_golang v1.20.5 - github.com/prometheus/common v0.60.1 - github.com/prometheus/exporter-toolkit v0.12.0 + github.com/oracle/oci-go-sdk/v65 v65.84.0 + github.com/prometheus/client_golang v1.21.0 + github.com/prometheus/common v0.62.0 + github.com/prometheus/exporter-toolkit v0.14.0 ) require ( @@ -24,7 +24,7 @@ require ( github.com/godror/knownpb v0.1.2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/jpillora/backoff v1.0.0 // indirect - github.com/klauspost/compress v1.17.9 // indirect + github.com/klauspost/compress v1.17.11 // indirect github.com/mdlayher/socket v0.4.1 // indirect github.com/mdlayher/vsock v1.2.1 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -33,13 +33,13 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/sony/gobreaker v0.5.0 // indirect github.com/xhit/go-str2duration/v2 v2.1.0 // indirect - golang.org/x/crypto v0.31.0 // indirect + golang.org/x/crypto v0.32.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/oauth2 v0.24.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect + golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect - google.golang.org/protobuf v1.34.2 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index aee7e64..c27a58e 100644 --- a/go.sum +++ b/go.sum @@ -55,6 +55,8 @@ github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4d github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= +github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -85,6 +87,8 @@ github.com/oracle/oci-go-sdk/v65 v65.79.0 h1:Tv9L1XTKWkdXtSViMbP+dA93WunquvW++/2 github.com/oracle/oci-go-sdk/v65 v65.79.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= github.com/oracle/oci-go-sdk/v65 v65.81.1 h1:JYc47bk8n/MUchA2KHu1ggsCQzlJZQLJ+tTKfOho00E= github.com/oracle/oci-go-sdk/v65 v65.81.1/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= +github.com/oracle/oci-go-sdk/v65 v65.84.0 h1:NCEiq42gwrFJPLmIMxz4QnZSM4Wmp6n+sjpznBDg060= +github.com/oracle/oci-go-sdk/v65 v65.84.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= @@ -93,6 +97,8 @@ github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zI github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= +github.com/prometheus/client_golang v1.21.0 h1:DIsaGmiaBkSangBgMtWdNfxbMNdku5IK6iNhrEqWvdA= +github.com/prometheus/client_golang v1.21.0/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo= @@ -101,12 +107,16 @@ github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJ github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= +github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= +github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= github.com/prometheus/exporter-toolkit v0.12.0 h1:DkE5RcEZR3lQA2QD5JLVQIf41dFKNsVMXFhgqcif7fo= github.com/prometheus/exporter-toolkit v0.12.0/go.mod h1:fQH0KtTn0yrrS0S82kqppRjDDiwMfIQUwT+RBRRhwUc= github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c= github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0= +github.com/prometheus/exporter-toolkit v0.14.0 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg= +github.com/prometheus/exporter-toolkit v0.14.0/go.mod h1:Gu5LnVvt7Nr/oqTBUC23WILZepW0nffNo10XdhQcwWA= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= @@ -132,6 +142,8 @@ golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= @@ -146,6 +158,8 @@ golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= @@ -157,11 +171,14 @@ golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= @@ -174,6 +191,8 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IV golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/main.go b/main.go index 2da1f05..035840c 100644 --- a/main.go +++ b/main.go @@ -6,13 +6,14 @@ package main import ( "context" + "github.com/prometheus/common/promslog" + "github.com/prometheus/common/promslog/flag" "net/http" "os" "runtime/debug" "syscall" "time" - "github.com/go-kit/log/level" "github.com/godror/godror/dsn" "github.com/prometheus/client_golang/prometheus" cversion "github.com/prometheus/client_golang/prometheus/collectors/version" @@ -22,8 +23,6 @@ import ( webflag "github.com/prometheus/exporter-toolkit/web/kingpinflag" "github.com/alecthomas/kingpin/v2" - "github.com/prometheus/common/promlog" - "github.com/prometheus/common/promlog/flag" // Required for debugging // _ "net/http/pprof" @@ -53,12 +52,12 @@ var ( ) func main() { - promLogConfig := &promlog.Config{} + promLogConfig := &promslog.Config{} flag.AddFlags(kingpin.CommandLine, promLogConfig) kingpin.HelpFlag.Short('\n') kingpin.Version(version.Print("oracledb_exporter")) kingpin.Parse() - logger := promlog.New(promLogConfig) + logger := promslog.New(promLogConfig) user := os.Getenv("DB_USERNAME") password := os.Getenv("DB_PASSWORD") connectString := os.Getenv("DB_CONNECT_STRING") @@ -69,22 +68,23 @@ func main() { vaultID, useVault := os.LookupEnv("OCI_VAULT_ID") if useVault { - level.Info(logger).Log("msg", "OCI_VAULT_ID env var is present so using OCI Vault", "vaultOCID", vaultID) + + logger.Info("OCI_VAULT_ID env var is present so using OCI Vault", "vaultOCID", vaultID) password = vault.GetVaultSecret(vaultID, os.Getenv("OCI_VAULT_SECRET_NAME")) } freeOSMemInterval, enableFree := os.LookupEnv("FREE_INTERVAL") if enableFree { - level.Info(logger).Log("msg", "FREE_INTERVAL env var is present, so will attempt to release OS memory", "free_interval", freeOSMemInterval) + logger.Info("FREE_INTERVAL env var is present, so will attempt to release OS memory", "free_interval", freeOSMemInterval) } else { - level.Info(logger).Log("msg", "FREE_INTERVAL end var is not present, will not periodically attempt to release memory") + logger.Info("FREE_INTERVAL end var is not present, will not periodically attempt to release memory") } restartInterval, enableRestart := os.LookupEnv("RESTART_INTERVAL") if enableRestart { - level.Info(logger).Log("msg", "RESTART_INTERVAL env var is present, so will restart my own process periodically", "restart_interval", restartInterval) + logger.Info("RESTART_INTERVAL env var is present, so will restart my own process periodically", "restart_interval", restartInterval) } else { - level.Info(logger).Log("msg", "RESTART_INTERVAL env var is not present, so will not restart myself periodically") + logger.Info("RESTART_INTERVAL env var is not present, so will not restart myself periodically") } config := &collector.Config{ @@ -105,7 +105,7 @@ func main() { } exporter, err := collector.NewExporter(logger, config) if err != nil { - level.Error(logger).Log("msg", "unable to connect to DB", "error", err) + logger.Error("unable to connect to DB", "error", err) } if *scrapeInterval != 0 { @@ -117,9 +117,9 @@ func main() { prometheus.MustRegister(exporter) prometheus.MustRegister(cversion.NewCollector("oracledb_exporter")) - level.Info(logger).Log("msg", "Starting oracledb_exporter", "version", Version) - level.Info(logger).Log("msg", "Build context", "build", version.BuildContext()) - level.Info(logger).Log("msg", "Collect from: ", "metricPath", *metricPath) + logger.Info("Starting oracledb_exporter", "version", Version) + logger.Info("Build context", "build", version.BuildContext()) + logger.Info("Collect from: ", "metricPath", *metricPath) opts := promhttp.HandlerOpts{ ErrorHandling: promhttp.ContinueOnError, @@ -133,14 +133,14 @@ func main() { if enableRestart { duration, err := time.ParseDuration(restartInterval) if err != nil { - level.Info(logger).Log("msg", "Could not parse RESTART_INTERVAL, so ignoring it") + logger.Info("Could not parse RESTART_INTERVAL, so ignoring it") } ticker := time.NewTicker(duration) defer ticker.Stop() go func() { <-ticker.C - level.Info(logger).Log("msg", "Restarting the process...") + logger.Info("Restarting the process...") executable, _ := os.Executable() execErr := syscall.Exec(executable, os.Args, os.Environ()) if execErr != nil { @@ -153,7 +153,7 @@ func main() { if enableFree { duration, err := time.ParseDuration(freeOSMemInterval) if err != nil { - level.Info(logger).Log("msg", "Could not parse FREE_INTERVAL, so ignoring it") + logger.Info("Could not parse FREE_INTERVAL, so ignoring it") } memTicker := time.NewTicker(duration) defer memTicker.Stop() @@ -161,7 +161,7 @@ func main() { go func() { for { <-memTicker.C - level.Info(logger).Log("msg", "attempting to free OS memory") + logger.Info("attempting to free OS memory") debug.FreeOSMemory() } }() @@ -170,16 +170,16 @@ func main() { // start the log exporter if *logDisable == 1 { - level.Info(logger).Log("msg", "log.disable set to 1, so will not export the alert logs") + logger.Info("log.disable set to 1, so will not export the alert logs") } else { - level.Info(logger).Log("msg", "Exporting alert logs to "+*logDestination) + logger.Info("Exporting alert logs to ", *logDestination) logTicker := time.NewTicker(*logInterval) defer logTicker.Stop() go func() { for { <-logTicker.C - level.Debug(logger).Log("msg", "updating alert log") + logger.Debug("updating alert log") alertlog.UpdateLog(*logDestination, logger, exporter.GetDB()) } }() @@ -188,7 +188,7 @@ func main() { // start the main server thread server := &http.Server{} if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil { - level.Error(logger).Log("msg", "Listening error", "error", err) + logger.Error("Listening error", "error", err) os.Exit(1) } diff --git a/vault/vault.go b/vault/vault.go index ce5a416..10c509b 100755 --- a/vault/vault.go +++ b/vault/vault.go @@ -1,4 +1,4 @@ -// Copyright (c) 2023, 2024, Oracle and/or its affiliates. +// Copyright (c) 2023, 2025, Oracle and/or its affiliates. // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. package vault @@ -6,18 +6,17 @@ package vault import ( "context" b64 "encoding/base64" + "github.com/prometheus/common/promslog" "strings" - "github.com/go-kit/log/level" "github.com/oracle/oci-go-sdk/v65/common" "github.com/oracle/oci-go-sdk/v65/example/helpers" "github.com/oracle/oci-go-sdk/v65/secrets" - "github.com/prometheus/common/promlog" ) func GetVaultSecret(vaultId string, secretName string) string { - promLogConfig := &promlog.Config{} - logger := promlog.New(promLogConfig) + promLogConfig := &promslog.Config{} + logger := promslog.New(promLogConfig) client, err := secrets.NewSecretsClientWithConfigurationProvider(common.DefaultConfigProvider()) helpers.FatalIfError(err) @@ -26,8 +25,8 @@ func GetVaultSecret(vaultId string, secretName string) string { helpers.FatalIfError(err) region, err := common.DefaultConfigProvider().Region() helpers.FatalIfError(err) - level.Info(logger).Log("msg", "OCI_VAULT_ID env var is present so using OCI Vault", "Region", region) - level.Info(logger).Log("msg", "OCI_VAULT_ID env var is present so using OCI Vault", "tenancyOCID", tenancyID) + logger.Info("OCI_VAULT_ID env var is present so using OCI Vault", "Region", region) + logger.Info("OCI_VAULT_ID env var is present so using OCI Vault", "tenancyOCID", tenancyID) req := secrets.GetSecretBundleByNameRequest{ SecretName: common.String(secretName), From 00e5d88de89f718608fa782f827f09ea0edb2de4 Mon Sep 17 00:00:00 2001 From: Anders Swanson Date: Fri, 28 Feb 2025 11:54:17 -0800 Subject: [PATCH 2/3] Package updates Signed-off-by: Anders Swanson --- go.mod | 1 - go.sum | 101 ++------------------------------------------------------- 2 files changed, 3 insertions(+), 99 deletions(-) diff --git a/go.mod b/go.mod index ebcc4e0..c78a3e3 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ toolchain go1.22.4 require ( github.com/BurntSushi/toml v1.4.0 github.com/alecthomas/kingpin/v2 v2.4.0 - github.com/go-kit/log v0.2.1 github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090 github.com/oracle/oci-go-sdk/v65 v65.84.0 github.com/prometheus/client_golang v1.21.0 diff --git a/go.sum b/go.sum index c27a58e..7850327 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc= -cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/UNO-SOFT/zlog v0.8.1 h1:TEFkGJHtUfTRgMkLZiAjLSHALjwSBdw6/zByMC5GJt4= @@ -17,44 +15,21 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godror/godror v0.44.6 h1:3Aw45jpKkPsss80DVy4/XiqXUPCsHmW0efSHBQFi0h4= -github.com/godror/godror v0.44.6/go.mod h1:KJwMtQpK9o3WdEiNw7qvgSk827YDLj9MV/bXSzvUzlo= -github.com/godror/godror v0.44.7 h1:fGxtxozidwBR3C1FVTrMiH77maOnMA4HqltDS/YM7O0= -github.com/godror/godror v0.44.7/go.mod h1:KJwMtQpK9o3WdEiNw7qvgSk827YDLj9MV/bXSzvUzlo= -github.com/godror/godror v0.44.8 h1:20AAK8BWZasXuRkX/vhbSpnAqBMXB9fngsdfMJ4pNgU= -github.com/godror/godror v0.44.8/go.mod h1:KJwMtQpK9o3WdEiNw7qvgSk827YDLj9MV/bXSzvUzlo= -github.com/godror/godror v0.45.1 h1:MnnUcU9/9rpLV3/Amv6kiT82pAlR0v5MFk/EXdKrblU= -github.com/godror/godror v0.45.1/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg= -github.com/godror/godror v0.45.2 h1:rkXxmD+/QdKz0PTOuSfEmWNFCHnKpWS8b8HUl+5V7us= -github.com/godror/godror v0.45.2/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg= -github.com/godror/godror v0.46.0 h1:/43db84UcoxlooASIsasH8TvZ7E1huwJ64yDtZ2504k= -github.com/godror/godror v0.46.0/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg= github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090 h1:9/ZPRz24+4QrrU/xB0I+AAXKzLV2xtG+mn+9zb3cQCg= github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg= github.com/godror/knownpb v0.1.2 h1:icMyYsYVpGmzhoVA01xyd0o4EaubR31JPK1UxQWe4kM= github.com/godror/knownpb v0.1.2/go.mod h1:zs9hH+lwj7mnPHPnKCcxdOGz38Axa9uT+97Ng+Nnu5s= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= -github.com/golang/protobuf v1.5.0 h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -67,54 +42,22 @@ github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= github.com/mdlayher/vsock v1.2.1/go.mod h1:NRfCibel++DgeMD8z/hP+PPTjlNJsdPOmxcnENvE+SE= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/ulid/v2 v2.0.2 h1:r4fFzBm+bv0wNKNh5eXTwU7i85y5x+uwkxCUTNVQqLc= github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68= -github.com/oracle/oci-go-sdk/v65 v65.73.0 h1:C7uel6CoKk4A1KPkdhFBAyvVyFRTHAmX8m0o64RmfPg= -github.com/oracle/oci-go-sdk/v65 v65.73.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= -github.com/oracle/oci-go-sdk/v65 v65.75.0 h1:tifYRSqCjxANJb0xnMSZ6N2bF2xGyqcCIMg7xihgk+s= -github.com/oracle/oci-go-sdk/v65 v65.75.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= -github.com/oracle/oci-go-sdk/v65 v65.77.1 h1:gqjTXIUWvTihkn470AclxSAMcR1JecqjD2IUtp+sDIU= -github.com/oracle/oci-go-sdk/v65 v65.77.1/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= -github.com/oracle/oci-go-sdk/v65 v65.79.0 h1:Tv9L1XTKWkdXtSViMbP+dA93WunquvW++/2s5pOvOgU= -github.com/oracle/oci-go-sdk/v65 v65.79.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= -github.com/oracle/oci-go-sdk/v65 v65.81.1 h1:JYc47bk8n/MUchA2KHu1ggsCQzlJZQLJ+tTKfOho00E= -github.com/oracle/oci-go-sdk/v65 v65.81.1/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= github.com/oracle/oci-go-sdk/v65 v65.84.0 h1:NCEiq42gwrFJPLmIMxz4QnZSM4Wmp6n+sjpznBDg060= github.com/oracle/oci-go-sdk/v65 v65.84.0/go.mod h1:IBEV9l1qBzUpo7zgGaRUhbB05BVfcDGYRFBCPlTcPp0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= -github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= -github.com/prometheus/client_golang v1.20.4 h1:Tgh3Yr67PaOv/uTqloMsCEdeuFTatm5zIq5+qNN23vI= -github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= -github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= -github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= github.com/prometheus/client_golang v1.21.0 h1:DIsaGmiaBkSangBgMtWdNfxbMNdku5IK6iNhrEqWvdA= github.com/prometheus/client_golang v1.21.0/go.mod h1:U9NM32ykUErtVBxdvD3zfi+EuFkkaBvMb09mIfe0Zgg= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.58.0 h1:N+N8vY4/23r6iYfD3UQZUoJPnUYAo7v6LG5XZxjZTXo= -github.com/prometheus/common v0.58.0/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= -github.com/prometheus/common v0.59.1 h1:LXb1quJHWm1P6wq/U824uxYi4Sg0oGvNeUm1z5dJoX0= -github.com/prometheus/common v0.59.1/go.mod h1:GpWM7dewqmVYcd7SmRaiWVe9SSqjf0UrwnYnpEZNuT0= -github.com/prometheus/common v0.60.1 h1:FUas6GcOw66yB/73KC+BOZoFJmbo/1pojoILArPAaSc= -github.com/prometheus/common v0.60.1/go.mod h1:h0LYf1R1deLSKtD4Vdg8gy4RuOvENW2J/h19V5NADQw= github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io= github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I= -github.com/prometheus/exporter-toolkit v0.11.0 h1:yNTsuZ0aNCNFQ3aFTD2uhPOvr4iD7fdBvKPAEGkNf+g= -github.com/prometheus/exporter-toolkit v0.11.0/go.mod h1:BVnENhnNecpwoTLiABx7mrPB/OLRIgN74qlQbV+FK1Q= -github.com/prometheus/exporter-toolkit v0.12.0 h1:DkE5RcEZR3lQA2QD5JLVQIf41dFKNsVMXFhgqcif7fo= -github.com/prometheus/exporter-toolkit v0.12.0/go.mod h1:fQH0KtTn0yrrS0S82kqppRjDDiwMfIQUwT+RBRRhwUc= -github.com/prometheus/exporter-toolkit v0.13.0 h1:lmA0Q+8IaXgmFRKw09RldZmZdnvu9wwcDLIXGmTPw1c= -github.com/prometheus/exporter-toolkit v0.13.0/go.mod h1:2uop99EZl80KdXhv/MxVI2181fMcwlsumFOqBecGkG0= github.com/prometheus/exporter-toolkit v0.14.0 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg= github.com/prometheus/exporter-toolkit v0.14.0/go.mod h1:Gu5LnVvt7Nr/oqTBUC23WILZepW0nffNo10XdhQcwWA= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= @@ -132,65 +75,27 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc= github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= -golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= -golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= -golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 49164bff1d2d3b7e85f5139e768030a5d4331c4b Mon Sep 17 00:00:00 2001 From: Anders Swanson Date: Fri, 28 Feb 2025 12:08:26 -0800 Subject: [PATCH 3/3] Package updates Signed-off-by: Anders Swanson --- collector/collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/collector.go b/collector/collector.go index 4747232..100e28a 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -266,7 +266,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { if len(metric.MetricsDesc) == 0 { errChan <- errors.New("metricsdesc not found") - e.logger.Error("Error scraping for query" + fmt.Sprint(metric.Request) + ". Did you forget to define metricsdesc in your toml file?") + e.logger.Error("Error scraping for query" + fmt.Sprint(metric.Request) + ". Did you forget to define metricsdesc in your toml file?") return }