Skip to content

Commit a394696

Browse files
Add current docs (#311)
Signed-off-by: Anders Swanson <[email protected]>
1 parent b71612e commit a394696

21 files changed

+1587
-7
lines changed

site/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
44

5+
The `content` directory contains the built, static site.
6+
57
Requirements:
68
- latest version of NodeJS
79

@@ -22,7 +24,9 @@ This command starts a local development server and opens up a browser window. Mo
2224
## Build
2325

2426
```bash
27+
rm -rf content
2528
npm run build
29+
cp -r build content
2630
```
2731

2832
## Versioning

site/docs/advanced/_category_.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"label": "Advanced",
3+
"position": 4,
4+
"link": {
5+
"type": "generated-index",
6+
"description": "Advanced configuration."
7+
}
8+
}

site/docs/advanced/development.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Development
3+
sidebar_position: 3
4+
---
5+
6+
# Development
7+
8+
The exporter is a Go program using the Prometheus SDK.
9+
10+
External contributions are welcome, see [CONTRIBUTING](https://github.com/oracle/oracle-db-appdev-monitoring/blob/main/CONTRIBUTING.md) for details.
11+
12+
The exporter initialization is as follows:
13+
14+
- Parse flags options and configuration properties
15+
- Load the default toml file (`default-metrics.toml`) and store each metric in a `Metric` struct
16+
- Load the custom toml file (if a custom toml file is given)
17+
- Create an `Exporter` object
18+
- Register exporter in prometheus library
19+
- Launching a web server to handle incoming requests
20+
- Attempt connection to any configured Oracle Database servers
21+
22+
These operations are mainly done in the `main` function.
23+
24+
After this initialization phase, the exporter will wait for the arrival of a request.
25+
26+
Each time, it will iterate over the content of the `metricsToScrape` structure (in the function scrape `func (e * Export) scrape (ch chan <- prometheus.Metric)`).
27+
28+
For each element (of `Metric` type), a call to the `ScrapeMetric` function will be made which will itself make a call to the `ScrapeGenericValues` function.
29+
30+
The `ScrapeGenericValues` function will read the information from the `Metric` structure and, depending on the parameters, will generate the metrics to return. In particular, it will use the `GeneratePrometheusMetrics` function which will make SQL calls to the database.
31+
32+
### Docker/container build
33+
34+
To build a container image, run the following command:
35+
36+
```bash
37+
make docker
38+
```
39+
40+
For ARM:
41+
42+
```bash
43+
make docker-arm
44+
```
45+
46+
### Building Binaries
47+
48+
Run build:
49+
50+
```bash
51+
make go-build
52+
```
53+
54+
This will create binaries and archives inside the `dist` folder for the building operating system.

site/docs/advanced/go-runtime.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Configuring the Go Runtime
3+
sidebar_position: 1
4+
---
5+
6+
# Exporter Go Runtime
7+
8+
If you are running in an environment with limited memory, or you are running a large number of exporters, you may want to control the exporter's usage of memory.
9+
10+
Under normal circumstances, the exporter process will retain OS memory that was used by the Go garbage collector but is no longer needed, in case it may be needed again in the future, unless the host OS is under memory pressure. The result of this behavior (which is the normal behavior of the Go runtime) is that the resident set size will not decrease until the host OS memory is almost all used. Under most circumstances, this will not cause any issues, but if you are in an environment where you need to conserve memory, the following options are provided:
11+
12+
- You may set the `FREE_INTERVAL` environment variable to a Go [duration string](https://pkg.go.dev/maze.io/x/duration), e.g., `60s` and run the exporter in debug mode by setting the `GODEBUG` environment variable to a value including `madvdontneed=1`, e.g., `GODEBUG=gctrace=1,madvdontneed=1`. The exporter will call the [FreeOSMemory()](https://pkg.go.dev/runtime/debug#FreeOSMemory) at the specified interval. This tells the Go runtime to attempt to release memory which is no longer needed. Please note that this does not guarantee that the memory will be released to the OS, but over time you should see the RSS shrink sooner than without these settings.
13+
- You may set the `RESTART_INTERVAL` environment variable to a Go [duration string](https://pkg.go.dev/maze.io/x/duration), e.g., `10m`. The exporter will restart its own process at the specified iterval (by calling the OS `exec` syscall). As no new process is created, the process identifier (PID) does not change, but the machine code, data, heap, and stack of the process are replaced by those of the new program (source: [Wikipedia](https://en.wikipedia.org/wiki/Exec_(system_call))). This has the side effect of freeing the resident set, so that it will return to its original size.
14+
- In addition to these, you may also set `GOMAXPROCS`, `GOGC`, and `GOMEMLIMIT` (see [documentation](https://pkg.go.dev/runtime#hdr-Environment_Variables)) to further limit the amount of resources that the Go runtime may use.

site/docs/advanced/txeventq.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: Monitoring TxEventQ
3+
sidebar_position: 2
4+
---
5+
6+
# Monitoring Transactional Event Queues
7+
8+
[Oracle Transactional Event Queues](https://docs.oracle.com/en/database/oracle/oracle-database/23/adque/index.html) ("TxEventQ") is a fault-tolerant, scalable, real-time messaging backbone offered by converged Oracle Database that allows you to build an enterprise-class event-driven architectures.
9+
10+
Access to the real-time broker, producer, and consumer metrics in a single dashboard and receiving alerts for issues allows teams to understand the state of their system.
11+
12+
The exporter includes a set of metrics for monitoring TxEventQ and a pre-built Grafana dashboard.
13+
14+
> Note: The metrics are written for Oracle Database 21c or later.
15+
16+
### How to create some traffic with PL/SQL
17+
18+
If you need to create a topic to monitor, you can use these statements to create and start a topic, and create a subscriber:
19+
20+
```sql
21+
declare
22+
subscriber sys.aq$_agent;
23+
begin
24+
-- create the topic
25+
dbms_aqadm.create_transactional_event_queue(
26+
queue_name => 'my_topic',
27+
multiple_consumers => true -- true makes a pub/sub topic
28+
);
29+
30+
-- start the topic
31+
dbms_aqadm.start_queue(
32+
queue_name => 'my_topic'
33+
);
34+
35+
-- create a subscriber
36+
dbms_aqadm.add_subscriber(
37+
queue_name => 'my_teq',
38+
subscriber => sys.aq$_agent(
39+
'my_subscriber', -- the subscriber name
40+
null, -- address, only used for notifications
41+
0 -- protocol
42+
),
43+
rule => 'correlation = ''my_subscriber'''
44+
);
45+
end;
46+
```
47+
48+
You can produce a message with these commands:
49+
50+
```sql
51+
declare
52+
enqueue_options dbms_aq.enqueue_options_t;
53+
message_properties dbms_aq.message_properties_t;
54+
message_handle raw(16);
55+
message SYS.AQ$_JMS_TEXT_MESSAGE;
56+
begin
57+
-- create the message payload
58+
message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
59+
message.set_text('{"orderid": 12345, "username": "Jessica Smith"}');
60+
61+
-- set the consumer name
62+
message_properties.correlation := 'my_subscriber';
63+
64+
-- enqueue the message
65+
dbms_aq.enqueue(
66+
queue_name => 'my_topic',
67+
enqueue_options => enqueue_options,
68+
message_properties => message_properties,
69+
payload => message,
70+
msgid => message_handle);
71+
72+
-- commit the transaction
73+
commit;
74+
end;
75+
```
76+
77+
### How to create some traffic with Java (Spring Boot)
78+
79+
A simple load generator is provided in [this directory](https://github.com/oracle/oracle-db-appdev-monitoring/tree/main/docker-compose/txeventq-load) which you can use to create some traffic so you can experiment with the sample dashboard.
80+
81+
To run the sample, first update [application.yaml](https://github.com/oracle/oracle-db-appdev-monitoring/blob/main/docker-compose/txeventq-load/src/main/resources/application.yaml) with the correct IP address for your database, then start the application as follows:
82+
83+
```bash
84+
mvn spring-boot:run
85+
```
86+
87+
The application will create ten queues names TOPIC_0 through TOPIC_9 and randomly produce and consume messages on those queues. The example dashboard shown below was monitoring traffic produced using this application.
88+
89+
### Metrics definitions
90+
91+
The metrics definitions are provided in [this file](https://github.com/oracle/oracle-db-appdev-monitoring/blob/main/custom-metrics-example/txeventq-metrics.toml). You need to provide this file to the exporter, e.g., by adding it to your container image, or creating a Kubernetes config map containing the file and mounting that config map as a volume in your deployment. You also need to set the `CUSTOM_METRICS` environment variable to the location of this file.
92+
93+
### Additional database permissions
94+
95+
The database user that the exporter uses to connect to the database will also need additional permissions, which can be granted with these statements. This example assumes the exporter connects with the username "exporter":
96+
97+
```sql
98+
grant execute on dbms_aq to exporter;
99+
grant execute on dbms_aqadm to exporter;
100+
grant execute on dbms_aqin to exporter;
101+
grant execute on dbms_aqjms_internal to exporter;
102+
grant execute on dbms_teqk to exporter;
103+
grant execute on DBMS_RESOURCE_MANAGER to exporter;
104+
grant select_catalog_role to exporter;
105+
grant select on sys.aq$_queue_shards to exporter;
106+
grant select on user_queue_partition_assignment_table to exporter;
107+
```
108+
109+
### Grafana dashboard
110+
111+
A Grafana dashboard for Transactional Event Queues is provided [in this file](https://github.com/oracle/oracle-db-appdev-monitoring/blob/main/docker-compose/grafana/dashboards/txeventq.json). This can be imported into your Grafana environment. Choose the Prometheus datasource that is collecting metrics from the exporter.
112+
113+
> Note: You may not see any activity on the dashboard unless there are clients producing and consuming messages from topics.
114+
115+
The dashboard will look like this:
116+
117+
![Oracle Database Dashboard](/img/txeventq-dashboard-v2.png)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Alert Logs
3+
sidebar_position: 5
4+
---
5+
6+
# Alert logs
7+
8+
Collect export alert logs with a log ingestion tool.
9+
10+
The exporter exports alert log records as a JSON file suitable for collection by a log ingestion tool like Promtail or FluentBit.
11+
12+
Alert logging is configured with the following parameters in the exporter config file:
13+
14+
| Parameter | Description | Default |
15+
|-----------------|-------------------------------|------------------|
16+
| log.destination | Log file path | `/log/alert.log` |
17+
| log.interval | Interval to log records | `15s` |
18+
| log.disable | Disable logging if set to `1` | `0` |
19+
20+
Example alert log YAML configuration:
21+
22+
```yaml
23+
log:
24+
# Path of log file
25+
destination: /opt/exporter/alert.log
26+
# Interval of log updates
27+
interval: 15s
28+
## Set disable to 1 to disable logging
29+
# disable: 0
30+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Azure Vault
3+
sidebar_position: 7
4+
---
5+
6+
# Azure Vault
7+
8+
Securely load database credentials from Azure Vault.
9+
10+
Each database in the config file may be configured to use Azure Vault. To load the database username and/or password from Azure Vault, set the `vault.azure` property to contain the Azure Vault ID, and secret names for the database username/password:
11+
12+
```yaml
13+
databases:
14+
mydb:
15+
vault:
16+
azure:
17+
id: <VAULT ID>
18+
usernameSecret: <Secret containing DB username>
19+
passwordSecret: <Secret containing DB password>
20+
```
21+
22+
### Authentication
23+
24+
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).
25+
26+
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).
27+
28+
You should set the following additional environment variables to allow the exporter to authenticate to Azure:
29+
30+
- `AZURE_TENANT_ID` should be set to your tenant ID
31+
- `AZURE_CLIENT_ID` should be set to the client ID to authenticate to Azure
32+
- `AZURE_CLIENT_SECRET` should be set to the client secret to authenticate to Azure
33+
34+
### Azure Vault CLI Configuration (without exporter config file)
35+
36+
If using the default database with CLI parameters, the exporter will read the database username and password from secrets stored in Azure Key Vault if you set these environment variables:
37+
38+
- `AZ_VAULT_ID` should be set to the ID of the Azure Key Vault that you wish to use
39+
- `AZ_VAULT_USERNAME_SECRET` should be set to the name of the secret in the Azure Key Vault which contains the database username
40+
- `AZ_VAULT_PASSWORD_SECRET` should be set to the name of the secret in the Azure Key Vault which contains the database password
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Exporter Config File
3+
sidebar_position: 1
4+
---
5+
6+
# Exporter Config File
7+
8+
The recommended way to configure the exporter is with the `--config.file` argument, specifying a YAML configuration file.
9+
10+
The configuration file contains the following options:
11+
12+
```yaml
13+
# Example Oracle Database Metrics Exporter Configuration file.
14+
# Environment variables of the form ${VAR_NAME} will be expanded.
15+
# If you include a config value that contains a '$' character, escape that '$' with another '$', e.g.,
16+
# "$test$pwd" => "$$test$$pwd"
17+
# Otherwise, the value will be expanded as an environment variable.
18+
19+
# Example Oracle Database Metrics Exporter Configuration file.
20+
# Environment variables of the form ${VAR_NAME} will be expanded.
21+
22+
databases:
23+
## Path on which metrics will be served
24+
# metricsPath: /metrics
25+
## Database connection information for the "default" database.
26+
default:
27+
## Database username
28+
username: ${DB_USERNAME}
29+
## Database password
30+
password: ${DB_PASSWORD}
31+
## Database password file
32+
## If specified, will load the database password from a file.
33+
# passwordFile: ${DB_PASSWORD_FILE}
34+
## Database connection url
35+
url: localhost:1521/freepdb1
36+
37+
## Metrics query timeout for this database, in seconds
38+
queryTimeout: 5
39+
40+
## Rely on Oracle Database External Authentication by network or OS
41+
# externalAuth: false
42+
## Database role
43+
# role: SYSDBA
44+
## Path to Oracle Database wallet, if using wallet
45+
# tnsAdmin: /path/to/database/wallet
46+
47+
### Connection settings:
48+
### Either the go-sql or Oracle Database connection pool may be used.
49+
### To use the Oracle Database connection pool over the go-sql connection pool,
50+
### set maxIdleConns to zero and configure the pool* settings.
51+
52+
### Connection pooling settings for the go-sql connection pool
53+
## Max open connections for this database using go-sql connection pool
54+
maxOpenConns: 10
55+
## Max idle connections for this database using go-sql connection pool
56+
maxIdleConns: 10
57+
58+
### Connection pooling settings for the Oracle Database connection pool
59+
## Oracle Database connection pool increment.
60+
# poolIncrement: 1
61+
## Oracle Database Connection pool maximum size
62+
# poolMaxConnections: 15
63+
## Oracle Database Connection pool minimum size
64+
# poolMinConnections: 15
65+
66+
## Arbitrary labels to add to each metric scraped from this database
67+
# labels:
68+
# label_name1: label_value1
69+
# label_name2: label_value2
70+
71+
metrics:
72+
## How often to scrape metrics. If not provided, metrics will be scraped on request.
73+
# scrapeInterval: 15s
74+
## Path to default metrics file.
75+
default: default-metrics.toml
76+
## Paths to any custom metrics files
77+
custom:
78+
- custom-metrics-example/custom-metrics.toml
79+
80+
log:
81+
# Path of log file
82+
destination: /opt/alert.log
83+
# Interval of log updates
84+
interval: 15s
85+
## Set disable to 1 to disable logging
86+
# disable: 0
87+
88+
# Optionally configure prometheus webserver
89+
#web:
90+
# listenAddresses: [':9161']
91+
# systemdSocket: true|false
92+
# configFile: /path/to/webconfigfile
93+
```
94+
95+
### Config file in a container image
96+
97+
To add your custom config file to a container image, you can layer the base exporter image and include that config:
98+
99+
```Dockerfile
100+
FROM container-registry.oracle.com/database/observability-exporter:2.0.2
101+
COPY my-exporter-config.yaml /
102+
ENTRYPOINT ["/oracledb_exporter", "--config.file", "/my-exporter-config.yaml"]
103+
```

site/docs/configuration/configuration.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)