Skip to content

[FEATURE] Add Splunk datasource plugin#543

Open
sharangokul28 wants to merge 1 commit intoperses:mainfrom
sharangokul28:feature/splunk-plugin
Open

[FEATURE] Add Splunk datasource plugin#543
sharangokul28 wants to merge 1 commit intoperses:mainfrom
sharangokul28:feature/splunk-plugin

Conversation

@sharangokul28
Copy link

@sharangokul28 sharangokul28 commented Jan 28, 2026

Description

The Splunk plugin enables Perses to connect to Splunk instances and query data using Splunk Processing Language (SPL). It supports both time series visualizations and log queries.

Screenshots

  1. Splunk endpoints
image
  1. Splunk datasource
image
  1. Splunk logs table panel
image
  1. Splunk time series chart panel
image

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

@AntoineThebaud AntoineThebaud changed the title [FEATURE] Splunk: new plugin for perses/plugin [FEATURE] Add Splunk datasource plugin Jan 28, 2026
@sharangokul28 sharangokul28 marked this pull request as ready for review January 28, 2026 09:12
@sharangokul28 sharangokul28 requested review from shahrokni and removed request for a team January 28, 2026 09:12
kind: "git"
}
deps: {
"github.com/perses/perses/cue@v0": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This package was moved. Older package still works but it will be removed in the future

Suggested change
"github.com/perses/perses/cue@v0": {
"github.com/perses/shared/cue@v0": {

@@ -0,0 +1,13 @@
module: "github.com/perses/plugins/splunk@v0"
language: {
version: "v0.14.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
version: "v0.14.0"
version: "v0.15.1"

}
deps: {
"github.com/perses/perses/cue@v0": {
v: "v0.53.0-beta.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
v: "v0.53.0-beta.3"
v: "v0.53.0-rc.1"

package model

import (
"github.com/perses/perses/cue/common"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"github.com/perses/perses/cue/common"
"github.com/perses/shared/cue/common"


import (
"github.com/perses/perses/cue/common"
commonProxy "github.com/perses/perses/cue/common/proxy"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
commonProxy "github.com/perses/perses/cue/common/proxy"
commonProxy "github.com/perses/shared/cue/common/proxy"

"build-mf": "rsbuild build",
"build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc",
"build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc",
"build:types": "tsc --project tsconfig.build.json",
Copy link
Contributor

Choose a reason for hiding this comment

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

The lint command is missing. This was added recently to the templates.

Suggested change
"build:types": "tsc --project tsconfig.build.json",
"build:types": "tsc --project tsconfig.build.json",
"lint": "eslint src --ext .ts,.tsx",

Comment on lines 19 to 21
"@perses-dev/components": "^0.53.0-beta.3",
"@perses-dev/core": "^0.53.0-beta.3",
"@perses-dev/plugin-system": "^0.53.0-beta.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"@perses-dev/components": "^0.53.0-beta.3",
"@perses-dev/core": "^0.53.0-beta.3",
"@perses-dev/plugin-system": "^0.53.0-beta.3",
"@perses-dev/components": "^0.53.0-rc.1",
"@perses-dev/core": "^0.53.0-rc.1",
"@perses-dev/plugin-system": "^0.53.0-rc.1",

splunk/go.mod Outdated

go 1.25.1

require github.com/perses/perses v0.53.0-beta.3
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
require github.com/perses/perses v0.53.0-beta.3
require github.com/perses/perses v0.53.0-rc.0

@Gladorme Gladorme self-requested a review January 29, 2026 14:16
Copy link
Contributor

@AntoineThebaud AntoineThebaud left a comment

Choose a reason for hiding this comment

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

CUE review following a change on main branch:

Signed-off-by: Sharan Gokul <sharangokul@gmail.com>
Copy link
Member

@Gladorme Gladorme left a comment

Choose a reason for hiding this comment

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

Nice PR!
First review done, ping me if you have any questions :)

}

const query = replaceVariables(spec.query, context.variableState);
const client = (await context.datasourceStore.getDatasourceClient<SplunkClient>(
Copy link
Member

Choose a reason for hiding this comment

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

  const client: SplunkClient = await context.datasourceStore.getDatasourceClient<SplunkClient>(
    spec.datasource ?? DEFAULT_DATASOURCE
  );

)) as SplunkClient;

const datasourceSpec = await context.datasourceStore.getDatasource(spec.datasource ?? DEFAULT_DATASOURCE);
const allowedEndpoints = (datasourceSpec.plugin.spec as any)?.proxy?.spec?.allowedEndpoints || [];
Copy link
Member

Choose a reason for hiding this comment

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

No need to do endpoint checks on client, if datasource do not have the necessary endpoint, it will trigger an error from the back.

Looking the code after, I can understand why there is check on client side: Splunk has two way to retrieve logs? I think we should only stick with the recommended one.

const earliest_time = Math.floor(start.getTime() / 1000).toString();
const latest_time = Math.floor(end.getTime() / 1000).toString();

let eventsResponse;
Copy link
Member

Choose a reason for hiding this comment

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

Perses is using TypeScript, for readibility and ease the maintenance for the future. Please provide typing for variables not initialized. It will be blocked by the linter in anycase. I saw some any too, except some cases, it should not be used

const indexesResponse = await client.getIndexes();
const entries = indexesResponse?.entry
? indexesResponse.entry.map((index) => ({
timestamp: new Date().getTime() / 1000,
Copy link
Member

Choose a reason for hiding this comment

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

Timestamp is not based on current timerange?

? indexesResponse.entry.map((index) => ({
timestamp: new Date().getTime() / 1000,
line: index.name,
labels: Object.fromEntries(
Copy link
Member

Choose a reason for hiding this comment

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

A comment to explain would be welcomed here, because I don't understand what is done here ^^"


return (
<Stack spacing={1.5} paddingBottom={1}>
<div>
Copy link
Member

Choose a reason for hiding this comment

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

Replace <div> by <Box> (MUI div)

}

const query = replaceVariables(spec.query, context.variableState);
const client = (await context.datasourceStore.getDatasourceClient<SplunkClient>(
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as get-splunk-log-data.ts

do {
await new Promise((resolve) => setTimeout(resolve, 500)); // Wait 500ms between polls
jobStatus = await client.getJobStatus(jobId);
} while (!jobStatus.entry?.[0]?.content?.isDone);
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as get-splunk-log-data.ts

const earliest_time = Math.floor(start.getTime() / 1000).toString();
const latest_time = Math.floor(end.getTime() / 1000).toString();

let resultsResponse;
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as get-splunk-log-data.ts

return {
series: convertedSeries,
timeRange: { start, end },
stepMs: context.suggestedStepMs || 60000,
Copy link
Member

Choose a reason for hiding this comment

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

Why 60000?

return response.json();
}

export async function exportSearch(
Copy link
Member

@Gladorme Gladorme Feb 17, 2026

Choose a reason for hiding this comment

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

This fetch looks like to be "streamed" when I look at the network inspect (result payload is displayed part by part), I wonder if we could use: https://tanstack.com/query/v5/docs/reference/streamedQuery 🤔

Never used it myself, but would ne nice if we don't have to wait full payload to display the content. Something that could be added in a future PR.

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.

4 participants