Skip to content

Commit c049e61

Browse files
eventing_app for CSC tests
1 parent f11fe6a commit c049e61

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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, EventingCommand, Configuration, Option, validators
22+
23+
24+
@Configuration()
25+
class EventingCSC(EventingCommand):
26+
"""
27+
The eventingapp command filters records from the events stream returning only those for which the status is same
28+
as search query.
29+
30+
Example:
31+
32+
``index="_internal" | head 4000 | eventingcsc status=200``
33+
34+
Returns records having status 200 as mentioned in search query.
35+
"""
36+
37+
status = Option(
38+
doc='''**Syntax:** **status=***<value>*
39+
**Description:** record having same status value will be returned.''',
40+
require=True)
41+
42+
def transform(self, records):
43+
for record in records:
44+
if str(self.status) == record["status"]:
45+
yield record
46+
47+
48+
dispatch(EventingCSC, 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 = Eventing App
11+
12+
[launcher]
13+
description = Eventing 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+
[eventingcsc]
2+
filename = eventingcsc.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/eventingcsc]
38+
access = read : [ * ], write : [ * ]
39+
export = system
40+
owner = Splunk

0 commit comments

Comments
 (0)