link:

http://dev.splunk.com/view/python-sdk/SP-CAAAER5

download SDK & setup with python

code:

import splunklib.client as client import splunklib.results as results import time

start = time.time()

HOST = "hostname"

PORT = 8089

USERNAME = "username"

PASSWORD = "password"

service = client.connect(

host=HOST,

port=PORT,

username=USERNAME,

password=PASSWORD)

kwargs_oneshot = {"earliest_time": "2017-07-01T12:00:00.000",

"latest_time": "2017-07-09T12:00:00.000",

"exec_mode": "blocking"}      # ,'search_mode': 'normal'

searchquery_oneshot = "search index=networkname netlinename|table rowname"

search_results = service.jobs.create(searchquery_oneshot, **kwargs_oneshot)

# Get the results and display them using the ResultsReader

rr = search_results.results(**{'count': 0})

reader = results.ResultsReader(rr)

inbound = []

outbound = []

for item in reader:

_raw_list = str(item['_raw'])

# print _raw_list

  inbound.append(_raw_list.split(",")[3])

outbound.append(_raw_list.split(",")[4])

# print inbound

# print outbound

print "inLen", len(inbound)

print "outLen", len(outbound)

print str(int(time.time() - start))

get data from splunk的更多相关文章

  1. splunk + docker-compose 实现自定义 index

    splunk是一款非常优秀的运维管理平台.Splunk 是机器数据的引擎.使用 Splunk 可收集.索引和利用所有应用程序.服务器和设备生成的快速移动型计算机数据 . 使用 Splunking 处理 ...

  2. 【SaltStack官方版】—— returners——返回器

    ETURNERS 返回器 By default the return values of the commands sent to the Salt minions are returned to t ...

  3. splunk 索引过程

    术语: Event :Events are records of activity in log files, stored in Splunk indexes. 简单说,处理的日志或话单中中一行记录 ...

  4. splunk rest api search

    如下: curl -u admin:changeme -k https://localhost:8089/services/search/jobs -d search="search sou ...

  5. 大数据工具——Splunk

    Splunk是机器数据的引擎.使用 Splunk 可收集.索引和利用所有应用程序.服务器和设备(物理.虚拟和云中)生成的快速移动型计算机数据 .从一个位置搜索并分析所有实时和历史数据. 使用 Splu ...

  6. Loading Data into HDFS

    How to use a PDI job to move a file into HDFS. Prerequisites In order to follow along with this how- ...

  7. Awesome Big Data List

    https://github.com/onurakpolat/awesome-bigdata A curated list of awesome big data frameworks, resour ...

  8. Coursera, Big Data 3, Integration and Processing (week 1/2/3)

    This is the 3rd course in big data specification courses. Data model reivew 1, data model 的特点: Struc ...

  9. Splunk 简单笔记

    Splunk Notes source="c:\logs\abc.log" | rex field=url "(?<=\/)(?<ApiId>\w+?) ...

随机推荐

  1. hdu 3333(树状数组 + 离线操作)

    Turing Tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. 【411】COMP9024 Assignment1 问题汇总

    1. 构建 Makefile 文件后运行错误,undefined reference to 'sqrt' 实际上是没有链接math数学库,所以要 $gcc test.c –lm //-lm就是链接到m ...

  3. Ubuntu12.04中新的快捷键(转载)

    转自:http://blog.51osos.com/linuxnews/ubuntu12-04%E4%B8%AD%E6%96%B0%E7%9A%84%E5%BF%AB%E6%8D%B7%E9%94%A ...

  4. Postgresql个人维护库时,出现有用户在连接又找不到这个用户是谁的强制中断连接的方法;

    方法一: 去PostgreSQL目录下/data/pgdata/9.4,找到pg_hba.conf, 修改pg_hba.conf的白名单IP (修改前,最好服务已停止,我是这么操作的) # IPv4 ...

  5. 通过爬虫爬取四川省公共资源交易平台上最近的招标信息 --- URLConnection

    通过爬虫爬取公共资源交易平台(四川省)最近的招标信息 一:引入JSON的相关的依赖 <dependency>       <groupId>net.sf.json-lib< ...

  6. idea 启动时报 error:java 无效的源发行版11

    编译的版本不符合,需要修改统一 

  7. ES6的新方法实现数组去重

    ES6里新添加了两个很好用的东西,set和Array.from. set是一种新的数据结构,它可以接收一个数组或者是类数组对象,自动去重其中的重复项目. 在这我们可以看见,重复的项目已经被去掉了,包括 ...

  8. 使用Navicat迁移MySQL数据至Oracle时大小写原因报“表或视图不存在”问题处理

    使用Navicat提供的数据传输工具将JEECMSv9的MySQL的数据迁移至Oracle数据库,数据迁移成功表都存在,但是在程序启动时提示表或视图不存在. Caused by: java.sql.S ...

  9. Android网络连接判断与检测

    转自: http://www.cnblogs.com/qingblog/archive/2012/07/19/2598983.html 本文主要内容: 1)判断是否有网络连接 2)判断WIFI网络是否 ...

  10. 1043 幸运号码 数位DP

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1043 设dp[i][j]表示前i位数中,i位数的和为j时的所有情况. 转 ...