Skip to content

TSDB Metrics with raw bin file import#3213

Merged
jmthomas merged 15 commits intomainfrom
tsdb_metrics
Apr 27, 2026
Merged

TSDB Metrics with raw bin file import#3213
jmthomas merged 15 commits intomainfrom
tsdb_metrics

Conversation

@jmthomas
Copy link
Copy Markdown
Member

@jmthomas jmthomas commented Apr 13, 2026

Calculate metrics across the entire TSDB:

image

Queries remains:

image

closes #3211

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 81.08808% with 73 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.43%. Comparing base (4a41799) to head (0ecee61).
⚠️ Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
...-cmd-tlm-api/app/controllers/storage_controller.rb 14.10% 67 Missing ⚠️
openc3/lib/openc3/script/script_runner.rb 0.00% 2 Missing ⚠️
openc3/lib/openc3/system/system.rb 71.42% 2 Missing ⚠️
openc3/lib/openc3/utilities/aws_bucket.rb 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3213      +/-   ##
==========================================
+ Coverage   78.37%   78.43%   +0.06%     
==========================================
  Files         675      680       +5     
  Lines       55600    55978     +378     
  Branches      728      728              
==========================================
+ Hits        43574    43909     +335     
- Misses      11948    11991      +43     
  Partials       78       78              
Flag Coverage Δ
python 79.51% <ø> (+<0.01%) ⬆️
ruby-api 82.47% <14.10%> (-1.17%) ⬇️
ruby-backend 81.83% <98.05%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@clayandgen clayandgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The eslint checks look real, would be good to address!

jmthomas and others added 2 commits April 21, 2026 23:46
Move raw-log reingest from Bucket Explorer into the Data Gap Analysis
dialog as a per-row Repair action, running async via ReingestJob. The
new DecomCommon module lets reingest skip check_limits on historical
data, groups files by embedded target hash, and falls back to 'current'
when the historical archive is missing. Metrics tab gains a
configurable data-gap sample interval.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread openc3-cosmos-cmd-tlm-api/app/controllers/storage_controller.rb Dismissed
@jmthomas jmthomas requested a review from ryanmelt April 22, 2026 21:47
Copy link
Copy Markdown
Contributor

@clayandgen clayandgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for splitting up the Vue files! Some further comments as the PR has grown...

Comment thread openc3-cosmos-cmd-tlm-api/app/controllers/storage_controller.rb
Comment thread openc3/lib/openc3/utilities/reingest_job.rb Outdated
Comment thread openc3/lib/openc3/system/system.rb
jmthomas and others added 2 commits April 23, 2026 17:22
- reingest_job: validate and inline target extraction from path; raise
  ReingestJobError when the path doesn't encode a target so the job marks
  Crashed with a clear message instead of ingesting against stale global
  System state and silently marking Complete
- storage_controller: reject non-identifier scope/target in repair_candidates
  so the S3 key prefix can't be reshaped by path separators or control
  characters (admin-only, defense in depth)
- tsdb tabs: extract the shared execSql helper into tsdbApi.js; TsdbMetrics
  and TsdbQueries import it instead of duplicating the retry logic

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread openc3/lib/openc3/utilities/reingest_job.rb
bucket_client.get_object(bucket: bucket_name, key: key, path: temp_file)
if File.extname(filename) == '.gz'
decompressed = BucketUtilities.uncompress_file(temp_file)
File.delete(temp_file)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path traversal attack possible - medium severity
A malicious actor could control the location of this file, which may allow them to retrieve, write or delete files outside of the intended folder.

Show fix

Remediation: To address this, ensure that user-controlled variables in file paths are sanitized at least to not contain '..' or forward slashes.

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

@jmthomas
Copy link
Copy Markdown
Member Author

To test you can run for a while and then disconnect INST or INST2. Then go into the TSDB Queries tab and issue the following (this is easier in the full QuestDB console if you enable that):

SELECT first(PACKET_TIMESECONDS) as first_ts, last(PACKET_TIMESECONDS) as last_ts FROM DEFAULT__TLM__INST__HEALTH_STATUS

Determine a good time range based on the above result and issue the following after changing the time range:

CREATE TABLE 'HEALTH_STATUS_REBUILD' AS (
    SELECT * FROM 'DEFAULT__TLM__INST__HEALTH_STATUS'
    WHERE PACKET_TIMESECONDS < '2026-04-24T22:00:00.000000Z'
       OR PACKET_TIMESECONDS > '2026-04-24T22:10:00.000000Z'
  ) TIMESTAMP(PACKET_TIMESECONDS) PARTITION BY DAY WAL
DROP TABLE 'DEFAULT__TLM__INST__HEALTH_STATUS'
RENAME TABLE 'HEALTH_STATUS_REBUILD' TO 'DEFAULT__TLM__INST__HEALTH_STATUS'

Reconnect INST and INST2 and graph INST HEALTH_STATUS TEMP1 with 1hr history. You'll see a 10min gap (using the values above).

image

Now you can go into the TSDB Metrics and perform a data gap analysis. You'll see the gap dialog and you can restore with the wrench.

image

It will prompt which raw files to re-import to cover the time period:

image

After processing and waiting for the DEDUP cooldown:

image

Clean graph!

image

@jmthomas jmthomas requested a review from clayandgen April 27, 2026 18:33
@jmthomas jmthomas changed the title Add TSDB Metrics TSDB Metrics with raw bin file import Apr 27, 2026
@jmthomas jmthomas added this to the COSMOS 7.1 milestone Apr 27, 2026
Copy link
Copy Markdown
Contributor

@clayandgen clayandgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome, and works great when I tried it! One small comment might be that the last dialog closes easily (clicking away from it). It could be good for that last dialog (waiting for dedup cooldown) to not close so easily so users can monitor it

@jmthomas jmthomas merged commit 3313640 into main Apr 27, 2026
29 of 30 checks passed
@jmthomas jmthomas deleted the tsdb_metrics branch April 27, 2026 23:31
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raw bin file import

3 participants