Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
174 changes: 9 additions & 165 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 14 additions & 16 deletions alertlog/alertlog.go
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {
Expand All @@ -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
}
Expand All @@ -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()
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}
Expand All @@ -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()
Expand All @@ -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
}

Expand All @@ -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++
}
}
Loading