Skip to content

Commit 756a791

Browse files
committed
[FEATURE] Splunk: new plugin for perses
Signed-off-by: Sharan Gokul <sharangokul@gmail.com>
1 parent f50d307 commit 756a791

45 files changed

Lines changed: 6349 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

splunk/README.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
# Splunk Plugin for Perses
2+
3+
This plugin provides Splunk datasource and query support for [Perses](https://github.com/perses/perses).
4+
5+
## Overview
6+
7+
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.
8+
9+
## Features
10+
11+
- **Splunk Datasource**: Connect to Splunk Enterprise or Splunk Cloud instances
12+
- **Time Series Queries**: Execute SPL queries for time series data visualization
13+
- **Log Queries**: Retrieve and display log data from Splunk
14+
- **Variable Support**: Use Perses variables in your SPL queries
15+
- **Flexible Authentication**: Support for direct URL or proxy-based connections
16+
17+
## Installation
18+
19+
This plugin is part of the Perses plugins repository. To use it:
20+
21+
1. Build the plugin:
22+
23+
```bash
24+
cd plugins/splunk
25+
npm install
26+
npm run build
27+
```
28+
29+
2. Configure Perses to load the plugin (see [Perses Plugin Documentation](https://perses.dev))
30+
31+
## Configuration
32+
33+
### Datasource Configuration
34+
35+
The Splunk datasource can be configured in two ways:
36+
37+
#### Direct URL
38+
39+
```yaml
40+
kind: Datasource
41+
metadata:
42+
name: my-splunk
43+
spec:
44+
plugin:
45+
kind: SplunkDatasource
46+
spec:
47+
directUrl: https://splunk.example.com:8089
48+
```
49+
50+
#### Proxy Configuration
51+
52+
```yaml
53+
kind: Datasource
54+
metadata:
55+
name: my-splunk
56+
spec:
57+
plugin:
58+
kind: SplunkDatasource
59+
spec:
60+
proxy:
61+
kind: HTTPProxy
62+
spec:
63+
url: https://splunk.example.com:8089
64+
allowedEndpoints:
65+
- endpointPattern: /services/search/jobs
66+
method: POST
67+
- endpointPattern: /services/search/jobs/([a-zA-Z0-9_.-]+)/results
68+
method: GET
69+
```
70+
71+
## Query Types
72+
73+
### Time Series Query
74+
75+
Use `SplunkTimeSeriesQuery` for visualizing metrics over time:
76+
77+
```yaml
78+
kind: TimeSeriesQuery
79+
spec:
80+
plugin:
81+
kind: SplunkTimeSeriesQuery
82+
spec:
83+
query: 'search index=main | timechart count by host'
84+
datasource:
85+
kind: SplunkDatasource
86+
name: my-splunk
87+
```
88+
89+
### Log Query
90+
91+
Use `SplunkLogQuery` for retrieving log data:
92+
93+
```yaml
94+
kind: LogQuery
95+
spec:
96+
plugin:
97+
kind: SplunkLogQuery
98+
spec:
99+
query: 'search index=main error | head 1000'
100+
datasource:
101+
kind: SplunkDatasource
102+
name: my-splunk
103+
maxResults: 1000
104+
```
105+
106+
## SPL Query Examples
107+
108+
### Time Series Examples
109+
110+
```spl
111+
# Count events over time
112+
search index=main | timechart count
113+
114+
# Average response time by service
115+
search index=web | timechart avg(response_time) by service
116+
117+
# Error rate over time
118+
search index=main error | timechart count
119+
```
120+
121+
### Log Query Examples
122+
123+
```spl
124+
# Recent errors
125+
search index=main error | head 100
126+
127+
# Specific application logs
128+
search index=app sourcetype=application:log level=ERROR
129+
130+
# Search with filters
131+
search index=main host=server01 status=500
132+
```
133+
134+
## Development
135+
136+
### Prerequisites
137+
138+
- Node.js version 22 or greater
139+
- npm version 10 or greater
140+
141+
### Running in Development Mode
142+
143+
1. In the main Perses repository, enable dev mode in `config.yaml`:
144+
145+
```yaml
146+
plugin:
147+
enable_dev: true
148+
```
149+
150+
2. Start the Perses backend:
151+
152+
```bash
153+
./scripts/api_backend_dev.sh
154+
```
155+
156+
3. Login with percli:
157+
158+
```bash
159+
percli login http://localhost:8080
160+
```
161+
162+
4. Start the plugin development server:
163+
164+
```bash
165+
percli plugin start /path/to/plugins/splunk
166+
```
167+
168+
## API Endpoints
169+
170+
The plugin uses the following Splunk REST API endpoints:
171+
172+
- `/services/search/jobs` - Create search jobs
173+
- `/services/search/jobs/{sid}` - Get job status
174+
- `/services/search/jobs/{sid}/results` - Get search results
175+
- `/services/search/jobs/{sid}/events` - Get search events
176+
- `/services/search/jobs/export` - Export search results
177+
- `/services/data/indexes` - Get index information
178+
179+
## Authentication
180+
181+
Splunk authentication can be configured through:
182+
183+
- HTTP headers (Authorization token)
184+
- Proxy settings with credentials
185+
- Direct URL with embedded credentials (not recommended for production)
186+
187+
Refer to the [Splunk REST API documentation](https://docs.splunk.com/Documentation/Splunk/latest/RESTREF/RESTprolog) for more details on authentication methods.
188+
189+
## License
190+
191+
This plugin is licensed under the Apache License, Version 2.0. See the [LICENSE](../../LICENSE) file for details.
192+
193+
## Contributing
194+
195+
Contributions are welcome! Please refer to the main [Perses contributing guidelines](https://github.com/perses/perses/blob/main/CONTRIBUTING.md).
196+
197+
## Support
198+
199+
For issues and questions:
200+
201+
- [Perses GitHub Issues](https://github.com/perses/perses/issues)
202+
- [Perses Documentation](https://perses.dev)

splunk/cue.mod/module.cue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module: "github.com/perses/plugins/splunk@v0"
2+
language: {
3+
version: "v0.14.0"
4+
}
5+
source: {
6+
kind: "git"
7+
}
8+
deps: {
9+
"github.com/perses/perses/cue@v0": {
10+
v: "v0.53.0-beta.3"
11+
default: true
12+
}
13+
}

splunk/go.mod

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module github.com/perses/plugins/splunk
2+
3+
go 1.25.1
4+
5+
require github.com/perses/perses v0.53.0-beta.3
6+
7+
require (
8+
github.com/beorn7/perks v1.0.1 // indirect
9+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
10+
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
11+
github.com/jpillora/backoff v1.0.0 // indirect
12+
github.com/kr/text v0.2.0 // indirect
13+
github.com/muhlemmer/gu v0.3.1 // indirect
14+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
15+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
16+
github.com/prometheus/client_golang v1.23.2 // indirect
17+
github.com/prometheus/client_model v0.6.2 // indirect
18+
github.com/prometheus/common v0.67.2 // indirect
19+
github.com/prometheus/procfs v0.17.0 // indirect
20+
github.com/zitadel/oidc/v3 v3.45.0 // indirect
21+
github.com/zitadel/schema v1.3.1 // indirect
22+
go.yaml.in/yaml/v2 v2.4.3 // indirect
23+
golang.org/x/net v0.46.0 // indirect
24+
golang.org/x/oauth2 v0.33.0 // indirect
25+
golang.org/x/sys v0.37.0 // indirect
26+
golang.org/x/text v0.30.0 // indirect
27+
google.golang.org/protobuf v1.36.10 // indirect
28+
gopkg.in/yaml.v3 v3.0.1 // indirect
29+
)

splunk/jest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Config } from '@jest/types';
2+
import shared from '../jest.shared';
3+
4+
const jestConfig: Config.InitialOptions = {
5+
...shared,
6+
7+
setupFilesAfterEnv: [...(shared.setupFilesAfterEnv ?? []), '<rootDir>/src/setup-tests.ts'],
8+
};
9+
10+
export default jestConfig;

0 commit comments

Comments
 (0)