Skip to content

Commit e18a71b

Browse files
authored
Add support for Azure Key Vault and updated deps (#204)
* udpate readme with auth details * update log message re auth * update tpl: * get username and password from az key vault * update godror * update toml * update prometheus * update oci sdk * update docs to prepare for release Signed-off-by: Mark Nelson <[email protected]>
1 parent d30e881 commit e18a71b

File tree

11 files changed

+390
-52
lines changed

11 files changed

+390
-52
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
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.5
6+
VERSION ?= 1.6.0
77
LDFLAGS := -X main.Version=$(VERSION)
88
GOFLAGS := -ldflags "$(LDFLAGS) -s -w"
99
BUILD_ARGS = --build-arg VERSION=$(VERSION)

README.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Contributions are welcome - please see [contributing](CONTRIBUTING.md).
1919
- [Kubernetes](#kubernetes)
2020
- [Standalone binary](#standalone-binary)
2121
- [Using OCI Vault](#using-oci-vault)
22+
- [Using Azure Vault](#using-azure-vault)
2223
- [Custom metrics](#custom-metrics)
2324
- [Controlling memory usage](#controlling-memory-usage)
2425
- [Grafana dashboards](#grafana-dashboards)
@@ -29,7 +30,8 @@ Contributions are welcome - please see [contributing](CONTRIBUTING.md).
2930

3031
| Release | Date | Changelog |
3132
|---------|----------------------|-----------------------------------------------------------------|
32-
| 1.5.5 | March 13th, 2025 | [1.5.5 Changelog](./changelog.md#version-155-march-13-2025) |
33+
| 1.6.0 | April 18, 2025 | [1.6.0 Changelog](./changelog.md#version-160-april-18-2025) |
34+
| 1.5.5 | March 13th, 2025 | [1.5.5 Changelog](./changelog.md#version-155-march-13-2025) |
3335
| 1.5.4 | March 3rd, 2025 | [1.5.4 Changelog](./changelog.md#version-154-march-3-2025) |
3436
| 1.5.3 | January 28th, 2025 | [1.5.3 Changelog](./changelog.md#version-153-january-28-2025) |
3537
| 1.5.2 | December 2nd, 2024 | [1.5.2 Changelog](./changelog.md#version-152-december-2-2024) |
@@ -374,7 +376,7 @@ docker run -it --rm \
374376
-e DB_PASSWORD=Welcome12345 \
375377
-e DB_CONNECT_STRING=free23ai:1521/freepdb \
376378
-p 9161:9161 \
377-
container-registry.oracle.com/database/observability-exporter:1.5.5
379+
container-registry.oracle.com/database/observability-exporter:1.6.0
378380
```
379381

380382
##### Using a wallet
@@ -420,7 +422,7 @@ docker run -it --rm \
420422
-e DB_CONNECT_STRING=devdb_tp \
421423
-v ./wallet:/wallet \
422424
-p 9161:9161 \
423-
container-registry.oracle.com/database/observability-exporter:1.5.5
425+
container-registry.oracle.com/database/observability-exporter:1.6.0
424426
```
425427
> **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`
426428

@@ -607,6 +609,27 @@ The exporter will read the password from a secret stored in OCI Vault if you set
607609

608610
> Note that the process must be running under a user that has the OCI CLI installed and configured correctly to access the desired tenancy and region. The OCI Profile used is `DEFAULT`.
609611

612+
### Using Azure Vault
613+
614+
The exporter will read the database username and password from secrets stored in Azure Key Vault if you set these environment variables:
615+
616+
- `AZ_VAULT_ID` should be set to the ID of the Azure Key Vault that you wish to use
617+
- `AZ_VAULT_USERNAME_SECRET` should be set to the name of the secret in the Azure Key Vault which contains the database username
618+
- `AZ_VAULT_PASSWORD_SECRET` should be set to the name of the secret in the Azure Key Vault which contains the database password
619+
620+
#### Authentication
621+
622+
If you are running the exporter outside Azure, we recommend using [application service principal](https://learn.microsoft.com/en-us/azure/developer/go/sdk/authentication/authentication-on-premises-apps).
623+
624+
If you are running the exporter inside Azure, we recommend using a [managed identity](https://learn.microsoft.com/en-us/azure/developer/go/sdk/authentication/authentication-azure-hosted-apps).
625+
626+
You should set the following additional environment variables to allow the exporter to authenticate to Azure:
627+
628+
- `AZURE_TENANT_ID` should be set to your tenant ID
629+
- `AZURE_CLIENT_ID` should be set to the client ID to authenticate to Azure
630+
- `AZURE_CLIENT_SECRET` should be set to the client secret to authenticate to Azure
631+
632+
610633
## Custom metrics
611634

612635
The exporter allows definition of arbitrary custom metrics in one or more TOML files. To specify this file to the
@@ -715,7 +738,7 @@ An exmaple of [custom metrics for Transacational Event Queues](./custom-metrics-
715738
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:
716739
717740
```Dockerfile
718-
FROM container-registry.oracle.com/database/observability-exporter:1.5.5
741+
FROM container-registry.oracle.com/database/observability-exporter:1.6.0
719742
COPY custom-metrics.toml /
720743
ENTRYPOINT ["/oracledb_exporter", "--custom.metrics", "/custom-metrics.toml"]
721744
```

THIRD_PARTY_LICENSES.txt

Lines changed: 160 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,86 @@ Copyright (c) 2016, 2025, Oracle and/or its affiliates.
1212

1313
----------------------------------- Licenses -----------------------------------
1414
- Apache-2.0
15+
- BSD-2-Clause
1516
- BSD-3-Clause
1617
- BSD-3-Clause--modified-by-Google
1718
- MIT
1819
- UPL-1.0
1920

2021
--------------------------------- (separator) ----------------------------------
2122

23+
== Dependency
24+
github.com/Azure/azure-sdk-for-go/sdk/azcore
25+
26+
== License Type
27+
SPDX:MIT
28+
29+
== Copyright
30+
Copyright (c) Microsoft Corporation.
31+
Copyright (c) Microsoft Corporation. All rights reserved.
32+
Copyright 2017 Microsoft Corporation. All rights reserved.
33+
34+
--------------------------------- (separator) ----------------------------------
35+
36+
== Dependency
37+
github.com/Azure/azure-sdk-for-go/sdk/azidentity
38+
39+
== License Type
40+
SPDX:MIT
41+
42+
== Copyright
43+
Copyright (c) Microsoft Corporation.
44+
Copyright (c) Microsoft Corporation. All rights reserved.
45+
46+
--------------------------------- (separator) ----------------------------------
47+
48+
== Dependency
49+
github.com/Azure/azure-sdk-for-go/sdk/internal
50+
51+
== License Type
52+
SPDX:MIT
53+
54+
== Copyright
55+
Copyright (c) Microsoft Corporation.
56+
Copyright (c) Microsoft Corporation. All rights reserved.
57+
Copyright 2017 Microsoft Corporation. All rights reserved.
58+
59+
--------------------------------- (separator) ----------------------------------
60+
61+
== Dependency
62+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets
63+
64+
== License Type
65+
SPDX:MIT
66+
67+
== Copyright
68+
Copyright (c) Microsoft Corporation. All rights reserved.
69+
70+
--------------------------------- (separator) ----------------------------------
71+
72+
== Dependency
73+
github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal
74+
75+
== License Type
76+
SPDX:MIT
77+
78+
== Copyright
79+
Copyright (c) Microsoft Corporation. All rights reserved.
80+
81+
--------------------------------- (separator) ----------------------------------
82+
83+
== Dependency
84+
github.com/AzureAD/microsoft-authentication-library-for-go
85+
86+
== License Type
87+
SPDX:MIT
88+
89+
== Copyright
90+
Copyright (c) Microsoft Corporation.
91+
Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License (the "License").
92+
93+
--------------------------------- (separator) ----------------------------------
94+
2295
== Dependency
2396
github.com/BurntSushi/toml
2497

@@ -505,6 +578,29 @@ Copyright 2019 Tim Heckman. All rights reserved. Use of this source code is
505578

506579
--------------------------------- (separator) ----------------------------------
507580

581+
== Dependency
582+
github.com/golang-jwt/jwt/v5
583+
584+
== License Type
585+
SPDX:MIT
586+
587+
== Copyright
588+
Copyright (c) 2012 Dave Grijalva
589+
Copyright (c) 2021 golang-jwt maintainers
590+
591+
--------------------------------- (separator) ----------------------------------
592+
593+
== Dependency
594+
github.com/google/uuid
595+
596+
== License Type
597+
SPDX:BSD-3-Clause--modified-by-Google
598+
599+
== Copyright
600+
Copyright 2023 Google Inc. All rights reserved.
601+
602+
--------------------------------- (separator) ----------------------------------
603+
508604
== Dependency
509605
github.com/jpillora/backoff
510606

@@ -643,6 +739,18 @@ Copyright 2016 The filepathx Authors
643739
Copyright 2016-2017 The New York Times Company
644740
Copyright 2021 The Go Authors. All rights reserved.
645741
Copyright 2023 Google LLC
742+
Copyright 2023+ Klaus Post. All rights reserved.
743+
744+
--------------------------------- (separator) ----------------------------------
745+
746+
== Dependency
747+
github.com/kylelemons/godebug
748+
749+
== License Type
750+
SPDX:Apache-2.0
751+
752+
== Copyright
753+
Copyright 2013 Google Inc. All rights reserved.
646754

647755
--------------------------------- (separator) ----------------------------------
648756

@@ -784,7 +892,18 @@ SPDX:Apache-2.0
784892
Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
785893

786894
== Notices
787-
Copyright (c) 2016, 2020, Oracle and/or its affiliates.
895+
Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates.
896+
897+
--------------------------------- (separator) ----------------------------------
898+
899+
== Dependency
900+
github.com/pkg/browser
901+
902+
== License Type
903+
SPDX:BSD-2-Clause
904+
905+
== Copyright
906+
Copyright (c) 2014, Dave Cheney <[email protected]>
788907

789908
--------------------------------- (separator) ----------------------------------
790909

@@ -851,7 +970,7 @@ SPDX:Apache-2.0
851970

852971
== Copyright
853972
Copyright 2020 The Prometheus-operator Authors
854-
Copyright 2024 The Prometheus Authors
973+
Copyright 2025 The Prometheus Authors
855974

856975
== Notices
857976
Common libraries shared by Prometheus Go components.
@@ -920,6 +1039,17 @@ Copyright 2010 The Go Authors. All rights reserved.
9201039

9211040
--------------------------------- (separator) ----------------------------------
9221041

1042+
== Dependency
1043+
github.com/youmark/pkcs8
1044+
1045+
== License Type
1046+
SPDX:MIT
1047+
1048+
== Copyright
1049+
Copyright (c) 2014 youmark
1050+
1051+
--------------------------------- (separator) ----------------------------------
1052+
9231053
== Dependency
9241054
golang.org/x/crypto
9251055

@@ -1023,7 +1153,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
10231153

10241154
== Copyright
10251155
Copyright 2009 The Go Authors.
1026-
Copyright 2024 The Go Authors. All rights reserved.
1156+
Copyright 2025 The Go Authors. All rights reserved.
10271157

10281158
== Patents
10291159
Additional IP Rights Grant (Patents)
@@ -1197,7 +1327,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11971327

11981328
== Copyright
11991329
Copyright 2009 The Go Authors.
1200-
Copyright 2024 The Go Authors. All rights reserved.
1330+
Copyright 2025 The Go Authors. All rights reserved.
12011331

12021332
== Patents
12031333
Additional IP Rights Grant (Patents)
@@ -1300,7 +1430,7 @@ SPDX:BSD-3-Clause--modified-by-Google
13001430

13011431
== Copyright
13021432
Copyright 2024 Google Inc. All rights reserved.
1303-
Copyright 2024 The Go Authors. All rights reserved.
1433+
Copyright 2025 The Go Authors. All rights reserved.
13041434

13051435
== Patents
13061436
Additional IP Rights Grant (Patents)
@@ -1357,8 +1487,30 @@ limitations under the License.
13571487

13581488
----------------------------------- Licenses -----------------------------------
13591489

1360-
--------------------------------- (separator) ----------------------------------
13611490
== SPDX:Apache-2.0
1491+
== SPDX:BSD-2-Clause
1492+
1493+
Redistribution and use in source and binary forms, with or without
1494+
modification, are permitted provided that the following conditions are met:
1495+
1496+
1. Redistributions of source code must retain the above copyright notice, this
1497+
list of conditions and the following disclaimer.
1498+
1499+
2. Redistributions in binary form must reproduce the above copyright notice,
1500+
this list of conditions and the following disclaimer in the documentation
1501+
and/or other materials provided with the distribution
1502+
1503+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1504+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1505+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1506+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1507+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1508+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1509+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1510+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1511+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1512+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1513+
13621514

13631515

13641516
--------------------------------- (separator) ----------------------------------
@@ -1414,5 +1566,5 @@ SOFTWARE.
14141566

14151567

14161568
=== ATTRIBUTION-HELPER-GENERATED:
1417-
=== Attribution helper version: {Major:0 Minor:11 GitVersion:0.10.0-114-g3747dab9 GitCommit:3747dab92eb29c0dbe6409ffbb824b9ae3a04b87 GitTreeState:clean BuildDate:2024-05-31T13:48:06Z GoVersion:go1.21.4 Compiler:gc Platform:linux/amd64}
1418-
=== License file based on go.mod with md5 sum: 771c94b3ddce81ff2e234b02d85209e4
1569+
=== Attribution helper version: {Major:0 Minor:11 GitVersion:0.10.0-116-g2a434e4d GitCommit:2a434e4d7eea22d4dfd2d1cf04909239d05562b1 GitTreeState:clean BuildDate:2025-04-17T14:57:55Z GoVersion:go1.23.7 Compiler:gc Platform:linux/amd64}
1570+
=== License file based on go.mod with md5 sum: e3aaf1f636118d333ec243eb9788fa19

azvault/azvault.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Copyright (c) 2023, 2025, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
3+
4+
package azvault
5+
6+
import (
7+
"context"
8+
"fmt"
9+
"os"
10+
"strings"
11+
12+
"github.com/prometheus/common/promslog"
13+
14+
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
15+
"github.com/Azure/azure-sdk-for-go/sdk/keyvault/azsecrets"
16+
)
17+
18+
func GetVaultSecret(vaultId string, secretName string) string {
19+
promLogConfig := &promslog.Config{}
20+
logger := promslog.New(promLogConfig)
21+
22+
vaultURI := fmt.Sprintf("https://%s.vault.azure.net/", vaultId)
23+
24+
// create a credential
25+
cred, err := azidentity.NewDefaultAzureCredential(nil)
26+
if err != nil {
27+
logger.Error("Failed to obtain an Azure Credential", "err", err)
28+
os.Exit(1)
29+
}
30+
31+
// establish a connection to the key vault client
32+
client, err := azsecrets.NewClient(vaultURI, cred, nil)
33+
if err != nil {
34+
logger.Error("Failed to create Azure Secrets Client", "err", err)
35+
os.Exit(1)
36+
}
37+
38+
// get the secret - empty string version means "latest"
39+
version := ""
40+
secret := ""
41+
resp, err := client.GetSecret(context.TODO(), secretName, version, nil)
42+
if err != nil {
43+
logger.Error("Failed to get secret from vault", "err", err)
44+
os.Exit(1)
45+
} else {
46+
secret = *resp.Value
47+
}
48+
49+
return strings.TrimRight(secret, "\r\n") // make sure a \r and/or \n didn't make it into the secret
50+
}

0 commit comments

Comments
 (0)