-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6907767
commit 8a7d9db
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
tests/searchcommands/test_apps/streaming_app/bin/streamingcsc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python | ||
# coding=utf-8 | ||
# | ||
# Copyright © 2011-2015 Splunk, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"): you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import os,sys | ||
|
||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) | ||
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators | ||
|
||
|
||
@Configuration() | ||
class StreamingCSC(StreamingCommand): | ||
""" | ||
The streamingapp command returns events with a one new field 'fahrenheit'. | ||
Example: | ||
``| makeresults count=5 | eval celsius = random()%100 | streamingcsc`` | ||
returns a records with one new filed 'fahrenheit'. | ||
""" | ||
|
||
def stream(self, records): | ||
for record in records: | ||
record["fahrenheit"] = (float(record["celsius"]) * 1.8) + 32 | ||
yield record | ||
|
||
|
||
dispatch(StreamingCSC, sys.argv, sys.stdin, sys.stdout, __name__) |
16 changes: 16 additions & 0 deletions
16
tests/searchcommands/test_apps/streaming_app/default/app.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Splunk app configuration file | ||
# | ||
|
||
[install] | ||
is_configured = 0 | ||
|
||
[ui] | ||
is_visible = 1 | ||
label = Streaming App | ||
|
||
[launcher] | ||
description = Streaming custom search commands example | ||
version = 1.0.0 | ||
author = Splunk | ||
|
4 changes: 4 additions & 0 deletions
4
tests/searchcommands/test_apps/streaming_app/default/commands.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[streamingcsc] | ||
filename = streamingcsc.py | ||
chunked = true | ||
python.version = python3 |
40 changes: 40 additions & 0 deletions
40
tests/searchcommands/test_apps/streaming_app/metadata/default.meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
# Application-level permissions | ||
|
||
[] | ||
access = read : [ * ], write : [ admin, power ] | ||
|
||
### EVENT TYPES | ||
|
||
[eventtypes] | ||
export = system | ||
|
||
|
||
### PROPS | ||
|
||
[props] | ||
export = system | ||
|
||
|
||
### TRANSFORMS | ||
|
||
[transforms] | ||
export = system | ||
|
||
|
||
### LOOKUPS | ||
|
||
[lookups] | ||
export = system | ||
|
||
|
||
### VIEWSTATES: even normal users should be able to create shared viewstates | ||
|
||
[viewstates] | ||
access = read : [ * ], write : [ * ] | ||
export = system | ||
|
||
[commands/streamingcsc] | ||
access = read : [ * ], write : [ * ] | ||
export = system | ||
owner = nobody |