-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add cht-sync collector and update the sql exporter example #111
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bf74bf9
feat: add cht-sync collector and update the sql exporter example
njuguna-n 6e82ec7
chore: set cht-sync as the default collector
njuguna-n 32c4903
fix: upadte collector file
njuguna-n c095898
chore: update default postgres connection string
njuguna-n caffe4e
feat: add hard coded schema and table name
njuguna-n bf0e215
update grafana json to have new cht-sync widget
mrjones-plip File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
collector_name: cht-sync | ||
|
||
# Update the schema and table names as needed | ||
queries: | ||
- query_name: couch2pg-query | ||
query: | | ||
SELECT | ||
split_part(seq,'-',1) as sequence, | ||
pending as pending, | ||
CASE | ||
WHEN updated_at < NOW() - INTERVAL '1 minute' THEN 0 | ||
ELSE 1 | ||
END AS liveness, | ||
split_part(source,'/',2) as db, | ||
split_part(source,'/',1) as cht_instance | ||
FROM | ||
v1.couchdb_progress | ||
WHERE | ||
source like '%/%' and | ||
seq like '%-%' | ||
ORDER BY | ||
cht_instance, db | ||
- query_name: dbt-latency | ||
query: | | ||
SELECT | ||
EXTRACT(EPOCH FROM(couchdb.latest - dbt_root.latest)) AS dbt_latency | ||
FROM | ||
(SELECT MAX(saved_timestamp) as latest FROM v1.document_metadata) dbt_root, | ||
(SELECT MAX(saved_timestamp) as latest FROM v1.couchdb) couchdb | ||
- query_name: dbt-run-stats | ||
query: | | ||
SELECT | ||
status, | ||
execution_time, | ||
name as table_name | ||
FROM | ||
v1.dbt_results | ||
|
||
metrics: | ||
- metric_name: couch2pg_progress_sequence | ||
type: counter | ||
help: 'current sequence number for couch2pg' | ||
key_labels: | ||
- db | ||
- cht_instance | ||
values: [sequence] | ||
query_ref: couch2pg-query | ||
- metric_name: couch2pg_progress_pending | ||
type: gauge | ||
help: 'approximate number of changes left to sync from couch to postgres' | ||
key_labels: | ||
- db | ||
- cht_instance | ||
values: [pending] | ||
query_ref: couch2pg-query | ||
- metric_name: couch2pg_up | ||
type: gauge | ||
help: '1 if couch2pg is running and has updated in the last minute, 0 if not' | ||
key_labels: | ||
- db | ||
- cht_instance | ||
values: [liveness] | ||
query_ref: couch2pg-query | ||
- metric_name: dbt_latency | ||
type: gauge | ||
help: 'difference between last timestamp in dbt models and current time (seconds)' | ||
values: [dbt_latency] | ||
query_ref: dbt-latency | ||
- metric_name: dbt_execution_time | ||
type: gauge | ||
help: 'dbt run last execution time (ms)' | ||
key_labels: | ||
- table_name | ||
values: [execution_time] | ||
query_ref: dbt-run-stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,16 @@ global: | |
max_connection_lifetime: 10m | ||
|
||
collector_files: | ||
- "/etc/sql_exporter/couch2pg_collector.yml" | ||
- "/etc/sql_exporter/cht_sync_collector.yml" | ||
|
||
jobs: | ||
- job_name: db_targets | ||
collectors: [couch2pg] | ||
collectors: [cht-sync] # change this to [couch2pg] to monitor couch2pg | ||
enable_ping: true | ||
static_configs: | ||
- targets: | ||
# change USERNAME, PASSWORD, DB_SERVER as needed. Likely DATABASE and PORT don't need to change. | ||
# be sure each new server gets a unique name. A good rule of thumb is to use the name of the | ||
# sql server (eg "postgres-rds-prod", "postgres-rds-dev1" etc.) | ||
# 'postgres://USERNAME:PASSWORD@DB_SERVER_IP/DATABASE:PORT | ||
"db1": 'postgres://cht_couch2pg:[email protected]:5432/cht?sslmode=disable' # //NOSONAR - password is safe to commit | ||
|
||
"db1": 'postgres://postgres:[email protected]:5432/data?sslmode=disable' # //NOSONAR - password is safe to commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('Happy developing ✨') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting an error:
Doing some digging in the actual data in my DB, this might work?
Checking prometheus targets at
http://localhost:9090/targets?search=
I seehttp://sql_exporter:9399/metrics
marked asUP
, and checking that URL I see metrics I'd expect:that all said, my couch2pg backlog panel in Grafana shows no data:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrjones-plip I suspect the first error you got is because your
POSTGRES_TABLE
env variable was set to medic but that was updated tocouchdb
in this commit. I have managed to replicate the No data issue but I don't know why since the SQL query works as expected. I have booked a 30 minute session in your calendar to go through this together and hopefully get this over the line.