Skip to content

Commit b7a0b7f

Browse files
authored
Add extra admin roles (#183)
* pickup change in godror to add extra admin roles * update doc, version * uptake new admin role api * update version nums * use AdminRole type instead of just string Signed-off-by: Mark Nelson <mark.x.nelson@oracle.com> --------- Signed-off-by: Mark Nelson <mark.x.nelson@oracle.com>
1 parent 5940f34 commit b7a0b7f

File tree

8 files changed

+55
-17
lines changed

8 files changed

+55
-17
lines changed

Diff for: Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
33
ARCH_TYPE ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
44
GOOS ?= $(shell go env GOOS)
55
GOARCH ?= $(shell go env GOARCH)
6-
VERSION ?= 1.5.3
6+
VERSION ?= 1.5.4
77
LDFLAGS := -X main.Version=$(VERSION)
88
GOFLAGS := -ldflags "$(LDFLAGS) -s -w"
99
BUILD_ARGS = --build-arg VERSION=$(VERSION)

Diff for: README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,31 @@ Contributions are welcome - please see [contributing](CONTRIBUTING.md).
2727

2828
## Release Notes
2929

30+
### Version 1.5.4, February 27, 2025
31+
32+
Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues
33+
with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release.
34+
35+
- Fix malloc error (#177)
36+
- Add support for additional admin roles, exapnding list of options for `DB_ROILE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180)
37+
- Updated some third-party dependencies.
38+
39+
Thank you to the following people for their suggestions and contributions:
40+
41+
- [@Jman1993](https://github.com/Jman1993)
42+
- [@oey](https://github.com/oey)
43+
- [@jlembeck06](https://github.com/jlembeck06)
44+
- [@Jman1993](https://github.com/Jman1993)
45+
- [@PeterP55P](https://github.com/PeterP55P)
46+
- [@rlagyu0](https://github.com/rlagyu0)
47+
48+
In this release, we also continued some minor code refactoring.
49+
3050
### Version 1.5.3, January 28, 2025
3151

52+
*Known issue*: This release has a known issue that results in the error message `malloc(): unsorted double linked list corrupted`.
53+
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.
54+
3255
Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues
3356
with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release.
3457

@@ -496,7 +519,7 @@ For a simple connection, you will provide the details using these variables:
496519
- `DB_USERNAME` is the database username, e.g., `pdbadmin`
497520
- `DB_PASSWORD` is the password for that user, e.g., `Welcome12345`
498521
- `DB_CONNECT_STRING` is the connection string, e.g., `free23ai:1521/freepdb`
499-
- `DB_ROLE` (Optional) can be set to `SYSDBA` or `SYSOPER` if you want to connect with one of those roles, however Oracle recommends that you connect with the lowest possible privileges and roles necessary for the exporter to run.
522+
- `DB_ROLE` (Optional) can be set to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` or `SYSASM` if you want to connect with one of those roles, however Oracle recommends that you connect with the lowest possible privileges and roles necessary for the exporter to run.
500523

501524
To run the exporter in a container and expose the port, use a command like this, with the appropriate values for the environment variables:
502525

@@ -506,7 +529,7 @@ docker run -it --rm \
506529
-e DB_PASSWORD=Welcome12345 \
507530
-e DB_CONNECT_STRING=free23ai:1521/freepdb \
508531
-p 9161:9161 \
509-
container-registry.oracle.com/database/observability-exporter:1.5.3
532+
container-registry.oracle.com/database/observability-exporter:1.5.4
510533
```
511534

512535
##### Using a wallet
@@ -552,7 +575,7 @@ docker run -it --rm \
552575
-e DB_CONNECT_STRING=devdb_tp \
553576
-v ./wallet:/wallet \
554577
-p 9161:9161 \
555-
container-registry.oracle.com/database/observability-exporter:1.5.3
578+
container-registry.oracle.com/database/observability-exporter:1.5.4
556579
```
557580
> **Note:** If you are using `podman` you must specify the `:z` suffix on the volume mount so that the container will be able to access the files in the volume. For example: `-v ./wallet:/wallet:z`
558581

@@ -842,7 +865,7 @@ An exmaple of [custom metrics for Transacational Event Queues](./custom-metrics-
842865
If you run the exporter as a container image and want to include your custom metrics in the image itself, you can use the following example `Dockerfile` to create a new image:
843866
844867
```Dockerfile
845-
FROM container-registry.oracle.com/database/observability-exporter:1.5.3
868+
FROM container-registry.oracle.com/database/observability-exporter:1.5.4
846869
COPY custom-metrics.toml /
847870
ENTRYPOINT ["/oracledb_exporter", "--custom.metrics", "/custom-metrics.toml"]
848871
```

Diff for: collector/collector.go

+19-7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/go-kit/log"
2424
"github.com/go-kit/log/level"
2525
"github.com/godror/godror"
26+
"github.com/godror/godror/dsn"
2627
"github.com/prometheus/client_golang/prometheus"
2728
)
2829

@@ -54,7 +55,7 @@ type Config struct {
5455
User string
5556
Password string
5657
ConnectString string
57-
DbRole string
58+
DbRole dsn.AdminRole
5859
ConfigDir string
5960
ExternalAuth bool
6061
MaxIdleConns int
@@ -401,12 +402,23 @@ func (e *Exporter) connect() error {
401402
// if TNS_ADMIN env var is set, set ConfigDir to that location
402403
P.ConfigDir = e.configDir
403404

404-
if strings.ToUpper(e.config.DbRole) == "SYSDBA" {
405-
P.IsSysDBA = true
406-
}
407-
408-
if strings.ToUpper(e.config.DbRole) == "SYSOPER" {
409-
P.IsSysOper = true
405+
switch e.config.DbRole {
406+
case "SYSDBA":
407+
P.AdminRole = dsn.SysDBA
408+
case "SYSOPER":
409+
P.AdminRole = dsn.SysOPER
410+
case "SYSBACKUP":
411+
P.AdminRole = dsn.SysBACKUP
412+
case "SYSDG":
413+
P.AdminRole = dsn.SysDG
414+
case "SYSKM":
415+
P.AdminRole = dsn.SysKM
416+
case "SYSRAC":
417+
P.AdminRole = dsn.SysRAC
418+
case "SYSASM":
419+
P.AdminRole = dsn.SysASM
420+
default:
421+
P.AdminRole = dsn.NoRole
410422
}
411423

412424
level.Debug(e.logger).Log("msg", "connection properties: "+fmt.Sprint(P))

Diff for: docker-compose/compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ services:
4343
start_period: 30s
4444

4545
exporter:
46-
image: container-registry.oracle.com/database/observability-exporter:1.5.3
46+
image: container-registry.oracle.com/database/observability-exporter:1.5.4
4747
container_name: exporter
4848
ports:
4949
- 9161:9161

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/BurntSushi/toml v1.4.0
99
github.com/alecthomas/kingpin/v2 v2.4.0
1010
github.com/go-kit/log v0.2.1
11-
github.com/godror/godror v0.46.0
11+
github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090
1212
github.com/oracle/oci-go-sdk/v65 v65.81.1
1313
github.com/prometheus/client_golang v1.20.5
1414
github.com/prometheus/common v0.60.1

Diff for: go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ github.com/godror/godror v0.45.2 h1:rkXxmD+/QdKz0PTOuSfEmWNFCHnKpWS8b8HUl+5V7us=
3434
github.com/godror/godror v0.45.2/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg=
3535
github.com/godror/godror v0.46.0 h1:/43db84UcoxlooASIsasH8TvZ7E1huwJ64yDtZ2504k=
3636
github.com/godror/godror v0.46.0/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg=
37+
github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090 h1:9/ZPRz24+4QrrU/xB0I+AAXKzLV2xtG+mn+9zb3cQCg=
38+
github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg=
3739
github.com/godror/knownpb v0.1.2 h1:icMyYsYVpGmzhoVA01xyd0o4EaubR31JPK1UxQWe4kM=
3840
github.com/godror/knownpb v0.1.2/go.mod h1:zs9hH+lwj7mnPHPnKCcxdOGz38Axa9uT+97Ng+Nnu5s=
3941
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=

Diff for: kubernetes/metrics-exporter-deployment.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ spec:
1717
spec:
1818
containers:
1919
- name: metrics-exporter
20-
image: container-registry.oracle.com/database/observability-exporter:1.5.3
20+
image: container-registry.oracle.com/database/observability-exporter:1.5.4
2121
imagePullPolicy: Always
2222
env:
2323
# uncomment and customize the next item if you want to provide custom metrics definitions

Diff for: main.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/go-kit/log/level"
16+
"github.com/godror/godror/dsn"
1617
"github.com/prometheus/client_golang/prometheus"
1718
cversion "github.com/prometheus/client_golang/prometheus/collectors/version"
1819
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -87,9 +88,9 @@ func main() {
8788
User: user,
8889
Password: password,
8990
ConnectString: connectString,
90-
DbRole: dbrole,
91+
DbRole: dsn.AdminRole(dbrole),
9192
ConfigDir: tnsadmin,
92-
ExternalAuth: externalAuth,
93+
ExternalAuth: externalAuth,
9394
MaxOpenConns: *maxOpenConns,
9495
MaxIdleConns: *maxIdleConns,
9596
CustomMetrics: *customMetrics,

0 commit comments

Comments
 (0)