Skip to content

pkg/plugin: pad missing _time rows in instant log frames#672

Open
immanuwell wants to merge 1 commit into
VictoriaMetrics:mainfrom
immanuwell:fix/pad-missing-time-instant-logs
Open

pkg/plugin: pad missing _time rows in instant log frames#672
immanuwell wants to merge 1 commit into
VictoriaMetrics:mainfrom
immanuwell:fix/pad-missing-time-instant-logs

Conversation

@immanuwell

@immanuwell immanuwell commented Jun 17, 2026

Copy link
Copy Markdown

Related issue: n/a

Describe Your Changes

Fix an edge case in instant log parsing.

If VictoriaLogs returns mixed rows where one row has _time and another one does not, the backend built a malformed frame with uneven field lengths, so Grafana just bails out.

This patch pads missing _time per row with the same fallback time already used when _time is missing for the whole response. Small fix, no extra behavior changes.

Repro:

  1. Add this fixture:
    {"_time":"2024-02-20T14:04:27Z","_msg":"123","_stream":"{app=\"test\"}"}
    {"_msg":"456","_stream":"{app=\"test\"}"}
  2. Run go test ./pkg/plugin -run Test_parseInstantResponse -count=1
  3. Before this patch it fails with frame has different field lengths
  4. With this patch it passes

Why this is real:
VictoriaLogs docs say logs without _time are ingested with the current timestamp, so mixed rows are totally possible in practice, not some weird unreachable corner.

Checklist


Summary by cubic

Pads missing _time values per row in instant log responses to prevent malformed frames and Grafana errors when rows mix with and without _time.

  • Bug Fixes
    • In parseInstantResponse, use a single fallbackTime from nowFunc() to fill missing per-row _time, and reuse it when the whole response lacks _time.
    • Added a test and fixture for mixed rows to ensure equal field lengths and valid frames.
    • Updated changelog entry to document the fix.

Written for commit c634834. Summary will update on new commits.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 4 files

Re-trigger cubic

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.

2 participants