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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH_TYPE ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
VERSION ?= 1.6.1
VERSION ?= 2.0.0
LDFLAGS := -X main.Version=$(VERSION)
GOFLAGS := -ldflags "$(LDFLAGS) -s -w"
BUILD_ARGS = --build-arg VERSION=$(VERSION)
Expand Down
146 changes: 13 additions & 133 deletions THIRD_PARTY_LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ Copyright 2010 The Go Authors. All rights reserved.

--------------------------------- (separator) ----------------------------------

== Dependency
github.com/VictoriaMetrics/easyproto

== License Type
SPDX:Apache-2.0

== Copyright
Copyright 2023-2024 VictoriaMetrics, Inc.

--------------------------------- (separator) ----------------------------------

== Dependency
github.com/alecthomas/kingpin/v2

Expand Down Expand Up @@ -612,137 +623,6 @@ Copyright (c) 2017 Jaime Pillora

--------------------------------- (separator) ----------------------------------

== Dependency
github.com/klauspost/compress

== License Type
=== BSD-3-Clause--modified-by-Google-d0fd9ebd
=== Apache-2.0
=== MIT
=== BSD-3-Clause--modified-by-Google
=== MIT
Copyright (c) 2012 The Go Authors. All rights reserved.
Copyright (c) 2019 Klaus Post. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

------------------

Files: gzhttp/*

SPDX:Apache-2.0

------------------

Files: s2/cmd/internal/readahead/*

The MIT License (MIT)

Copyright (c) 2015 Klaus Post

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

---------------------
Files: snappy/*
Files: internal/snapref/*

Copyright (c) 2011 The Snappy-Go Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-----------------

Files: s2/cmd/internal/filepathx/*

Copyright 2016 The filepathx Authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



== Copyright
Copyright (c) 2013, Yann Collet, released under BSD License.
Copyright (c) 2015, Pierre Curto
Copyright (c) 2016 Caleb Spare
Copyright (c) 2016 Evan Huus
Copyright (c) 2024+ Klaus Post. All rights reserved.
Copyright 2016 The Snappy-Go Authors. All rights reserved.
Copyright 2016 The filepathx Authors
Copyright 2016-2017 The New York Times Company
Copyright 2021 The Go Authors. All rights reserved.
Copyright 2023 Google LLC
Copyright 2023+ Klaus Post. All rights reserved.

--------------------------------- (separator) ----------------------------------

== Dependency
github.com/kylelemons/godebug

Expand Down Expand Up @@ -1566,5 +1446,5 @@ SOFTWARE.


=== ATTRIBUTION-HELPER-GENERATED:
=== 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}
=== License file based on go.mod with md5 sum: e3aaf1f636118d333ec243eb9788fa19
=== Attribution helper version: {Major:0 Minor:11 GitVersion:0.10.0-116-g2a434e4d-dirty GitCommit:2a434e4d7eea22d4dfd2d1cf04909239d05562b1 GitTreeState:dirty BuildDate:2025-04-29T00:30:45Z GoVersion:go1.22.4 Compiler:gc Platform:linux/amd64}
=== License file based on go.mod with md5 sum: 8b2013f9c4f6808e20b272f9ecfa05b2
6 changes: 3 additions & 3 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
ch <- e.error
e.scrapeErrors.Collect(ch)
for _, db := range e.databases {
ch <- db.DBtypeGauge
ch <- db.UpGauge
ch <- db.DBTypeMetric()
ch <- db.UpMetric()
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func (e *Exporter) scheduledScrape(tick *time.Time) {
metricCh <- e.error
e.scrapeErrors.Collect(metricCh)
for _, db := range e.databases {
metricCh <- db.UpGauge
metricCh <- db.UpMetric()
}
close(metricCh)
wg.Wait()
Expand Down
41 changes: 26 additions & 15 deletions collector/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,32 @@ import (
"time"
)

func (d *Database) UpMetric() prometheus.Metric {
desc := prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "up"),
"Whether the Oracle database server is up.",
nil,
d.constLabels(),
)
return prometheus.MustNewConstMetric(desc,
prometheus.GaugeValue,
d.Up,
)
}

func (d *Database) DBTypeMetric() prometheus.Metric {
desc := prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "dbtype"),
"Type of database the exporter is connected to (0=non-CDB, 1=CDB, >1=PDB).",
nil,
d.constLabels(),
)
return prometheus.MustNewConstMetric(desc,
prometheus.GaugeValue,
d.Type,
)
}

func (d *Database) ping(logger *slog.Logger) error {
err := d.Session.Ping()
if err != nil {
Expand All @@ -27,9 +53,6 @@ func (d *Database) ping(logger *slog.Logger) error {
} else {
d.Up = 1
}

d.UpGauge.Set(d.Up)
d.DBtypeGauge.Set(d.Type)
return err
}

Expand All @@ -48,18 +71,6 @@ func NewDatabase(logger *slog.Logger, dbname string, dbconfig DatabaseConfig) *D
Session: db,
Type: dbtype,
Config: dbconfig,
UpGauge: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: dbname,
Name: "up",
Help: "Whether the Oracle database server is up.",
}),
DBtypeGauge: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Subsystem: dbname,
Name: "dbtype",
Help: "Type of database the exporter is connected to (0=non-CDB, 1=CDB, >1=PDB).",
}),
}
}

Expand Down
12 changes: 5 additions & 7 deletions collector/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ type Exporter struct {
}

type Database struct {
Name string
Up float64
Session *sql.DB
Type float64
Config DatabaseConfig
UpGauge prometheus.Gauge
DBtypeGauge prometheus.Gauge
Name string
Up float64
Session *sql.DB
Type float64
Config DatabaseConfig
}

type Config struct {
Expand Down
33 changes: 26 additions & 7 deletions docker-compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,45 @@ services:
retries: 5
start_period: 30s

second23ai:
image: gvenzl/oracle-free:23.6-slim-faststart
container_name: second23ai
ports:
- 1522:1521
environment:
- ORACLE_PASSWORD=Welcome12345
volumes:
- ./oracle:/container-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "lsnrctl status | grep READY"]
interval: 15s
timeout: 10s
retries: 5
start_period: 30s

exporter:
image: container-registry.oracle.com/database/observability-exporter:1.6.1
image: container-registry.oracle.com/database/observability-exporter:2.0.0
container_name: exporter
# command:
command:
- '--config.file=/exporter/config.yaml'
# - '--log.level=debug'
# - '--database.maxIdleConns=10'
# - '--database.maxOpenConns=10'
ports:
- 9161:9161
environment:
- DB_USERNAME=pdbadmin
- DB_PASSWORD=Welcome12345
- DB_CONNECT_STRING=free23ai:1521/freepdb1
- CUSTOM_METRICS=/exporter/txeventq-metrics.toml,/exporter/more-txeventq-metrics.toml
# environment:
# - DB_USERNAME=pdbadmin
# - DB_PASSWORD=Welcome12345
# - DB_CONNECT_STRING=free23ai:1521/freepdb1
# - CUSTOM_METRICS=/exporter/txeventq-metrics.toml,/exporter/more-txeventq-metrics.toml
volumes:
- ./exporter:/exporter

depends_on:
free23ai:
condition: service_healthy
second23ai:
condition: service_healthy

volumes:
prom_data:
Loading