Skip to content

Commit 8a7d9db

Browse files
streaming_app for CSC tests
1 parent 6907767 commit 8a7d9db

File tree

4 files changed

+102
-0
lines changed

4 files changed

+102
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
#
4+
# Copyright © 2011-2015 Splunk, Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
7+
# not use this file except in compliance with the License. You may obtain
8+
# a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
18+
import os,sys
19+
20+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
21+
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators
22+
23+
24+
@Configuration()
25+
class StreamingCSC(StreamingCommand):
26+
"""
27+
The streamingapp command returns events with a one new field 'fahrenheit'.
28+
29+
Example:
30+
31+
``| makeresults count=5 | eval celsius = random()%100 | streamingcsc``
32+
33+
returns a records with one new filed 'fahrenheit'.
34+
"""
35+
36+
def stream(self, records):
37+
for record in records:
38+
record["fahrenheit"] = (float(record["celsius"]) * 1.8) + 32
39+
yield record
40+
41+
42+
dispatch(StreamingCSC, sys.argv, sys.stdin, sys.stdout, __name__)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Splunk app configuration file
3+
#
4+
5+
[install]
6+
is_configured = 0
7+
8+
[ui]
9+
is_visible = 1
10+
label = Streaming App
11+
12+
[launcher]
13+
description = Streaming custom search commands example
14+
version = 1.0.0
15+
author = Splunk
16+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[streamingcsc]
2+
filename = streamingcsc.py
3+
chunked = true
4+
python.version = python3
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# Application-level permissions
3+
4+
[]
5+
access = read : [ * ], write : [ admin, power ]
6+
7+
### EVENT TYPES
8+
9+
[eventtypes]
10+
export = system
11+
12+
13+
### PROPS
14+
15+
[props]
16+
export = system
17+
18+
19+
### TRANSFORMS
20+
21+
[transforms]
22+
export = system
23+
24+
25+
### LOOKUPS
26+
27+
[lookups]
28+
export = system
29+
30+
31+
### VIEWSTATES: even normal users should be able to create shared viewstates
32+
33+
[viewstates]
34+
access = read : [ * ], write : [ * ]
35+
export = system
36+
37+
[commands/streamingcsc]
38+
access = read : [ * ], write : [ * ]
39+
export = system
40+
owner = nobody

0 commit comments

Comments
 (0)