
下午好
今天,我们想与您分享10月初举行的年度大型活动Splunk .conf18的内部人士。 Splunk .conf是Splunk专家和开发人员共享经验,各种文章和有用的工作工具的地方。
在两篇文章中,我们将讨论会议上为仪表板开发人员提供的10种生活技巧。 我们为什么要谈论这个? 因为应用程序看起来越好,所以在其中感知的信息越好。 为了制作出非常好的仪表板,已经有很多内置或易于集成的工具,尽管并非所有人都知道在哪里以及如何找到它们。 了解更多有关它们以及如何使用它们的信息,请参见“裁减”。
为了在Splunk中开发高级仪表板,建议至少熟悉以下内容:
但是,即使您不熟悉,对于不是很复杂的事情(但仍超出基本自动可视化的范围),您都可以找到示例,空白或自己快速找到答案。
0. Splunk仪表板示例

在继续使用特定芯片之前,应该注意的是,有一个特殊的应用程序,具有各种复杂程度的仪表板示例以及这些仪表板后面的脚本。 通常,在浏览完此应用程序后,您将获得想法,了解如何实现特定图表,找到CSS和JS脚本模板,这是一件有用的事情。

您可以下载
链接 。
1.开发方式
为了避免在仪表板开发期间出现许多错误,尤其是在测试css和js时,建议对缓存和更新过程进行更改。
Web.conf
您需要创建(或修改)配置文件/etc/system/local/web.conf,并添加以下设置:
[settings]
minify_js = False
minify_css = False
js_no_cache = True
cacheEntriesLimit = 0
cacheBytesLimit = 0
enableWebDebug = True
浏览器
禁用浏览器中的缓存。
例如,对于谷歌浏览器,可以在“页面代码”部分中完成此操作:

选择性更新
应该注意的是,不仅可以通过命令行或Web界面,还可以通过URL重新启动Splunk:
http://localhost:8000/en-US/debug/refresh
如此一来,您将获得一份报告,其中已更新了约100个项目(有时需要很长时间)
检举Entity refresh control page
===========================
'''
Forces a refresh on splunkd resources
This method calls a splunkd refresh on all registered EAI handlers that
advertise a reload function. Alternate entities can be specified by appending
them via URI parameters. For example,
http://localhost:8000/debug/refresh?entity=admin/conf-times&entity=data/ui/manager
will request a refresh on only 'admin/conf-times' and 'data/ui/manager'.
1) not all splunkd endpoints support refreshing.
2) auth-services is excluded from the default set, as refreshing that system will
logout the current user; use the 'entity' param to force it
'''
Refreshing admin/conf-times OK
Refreshing data/ui/manager OK
Refreshing data/ui/nav OK
Refreshing data/ui/views OK
Refreshing admin/MonitorNoHandle OK
Refreshing admin/WinEventLog OK
Refreshing admin/WinHostMon OK
Refreshing admin/WinNetMon OK
Refreshing admin/WinPrintMon OK
Refreshing admin/WinRegMon OK
Refreshing admin/alert_actions OK
Refreshing admin/applicense OK
Refreshing admin/clusterconfig OK
Refreshing admin/collections-conf OK
Refreshing admin/commandsconf OK
Refreshing admin/conf-checklist OK
Refreshing admin/conf-deploymentclient OK
Refreshing admin/conf-inputs OK
Refreshing admin/conf-times OK
Refreshing admin/conf-wmi OK
Refreshing admin/cooked OK
Refreshing admin/crl ResourceNotFound Invalid action for this internal handler (handler: crl, supported: list|_reload, wanted: list).
Refreshing admin/datamodel-files OK
Refreshing admin/datamodelacceleration OK
Refreshing admin/datamodeledit OK
Refreshing admin/dataset_consolidation_datamodeleditOK
Refreshing admin/deploymentserver OK
Refreshing admin/distsearch-peer OK
Refreshing admin/eventtypes OK
Refreshing admin/fields OK
Refreshing admin/fvtags OK
Refreshing admin/health-report-config OK
Refreshing admin/http OK
Refreshing admin/index-archiver OK
Refreshing admin/indexer-discovery-configOK
Refreshing admin/indexes OK
Refreshing admin/limits OK
Refreshing admin/livetail OK
Refreshing admin/localapps OK
Refreshing admin/lookup-table-files OK
Refreshing admin/macros OK
Refreshing admin/manager OK
Refreshing admin/messages-conf OK
Refreshing admin/metrics-reload OK
Refreshing admin/modalerts OK
Refreshing admin/modinput_eventgen OK
Refreshing admin/monitor OK
Refreshing admin/msftapps_winfra_configuredOK
Refreshing admin/nav OK
Refreshing admin/nginx_status OK
Refreshing admin/panels OK
Refreshing admin/passwords OK
Refreshing admin/pools OK
Refreshing admin/powershell OK
Refreshing admin/powershell2 OK
Refreshing admin/proxysettings OK
Refreshing admin/quickstart OK
Refreshing admin/raw OK
Refreshing admin/remote_eventlogs OK
Refreshing admin/remote_indexes BadRequest The following required arguments are missing: repositoryLocation.
Refreshing admin/remote_monitor OK
Refreshing admin/remote_perfmon OK
Refreshing admin/remote_raw OK
Refreshing admin/remote_script OK
Refreshing admin/remote_udp OK
Refreshing admin/savedsearch OK
Refreshing admin/scheduledviews OK
Refreshing admin/script OK
Refreshing admin/search-head-bundles OK
Refreshing admin/serverclasses OK
Refreshing admin/shclusterconfig OK
Refreshing admin/sourcetypes OK
Refreshing admin/splunktcptoken OK
Refreshing admin/ssl OK
Refreshing admin/syslog OK
Refreshing admin/tcpout-default OK
Refreshing admin/tcpout-group OK
Refreshing admin/tcpout-server OK
Refreshing admin/telemetry OK
Refreshing admin/transforms-extract OK
Refreshing admin/transforms-lookup OK
Refreshing admin/transforms-reload OK
Refreshing admin/transforms-statsd OK
Refreshing admin/udp OK
Refreshing admin/ui-prefs OK
Refreshing admin/ui-tour OK
Refreshing admin/views OK
Refreshing admin/viewstates OK
Refreshing admin/visualizations OK
Refreshing admin/vix-indexes OK
Refreshing admin/vix-providers OK
Refreshing admin/win-admon OK
Refreshing admin/win-event-log-collectionsOK
Refreshing admin/win-eventlogs OK
Refreshing admin/win-perfmon OK
Refreshing admin/win-regmon OK
Refreshing admin/win-wmi-collections OK
Refreshing admin/workflow-actions OK
DONE
但是并非总是需要更新所有内容,因此在通过
/ debug / refresh更新的情况下
,您可以指定需要重新加载的特定元素。
允许您仅重新加载导航文件和仪表板本身的URL示例:
http://localhost:8000/en-US/debug/refresh?entity=data/ui/views&entity=data/ui/nav
报告:
Entity refresh control page
===========================
'''
Forces a refresh on splunkd resources
This method calls a splunkd refresh on all registered EAI handlers that
advertise a reload function. Alternate entities can be specified by appending
them via URI parameters. For example,
http://localhost:8000/debug/refresh?entity=admin/conf-times&entity=data/ui/manager
will request a refresh on only 'admin/conf-times' and 'data/ui/manager'.
1) not all splunkd endpoints support refreshing.
2) auth-services is excluded from the default set, as refreshing that system will
logout the current user; use the 'entity' param to force it
'''
Refreshing data/ui/views OK
Refreshing data/ui/nav OK
DONE
2.动态内容
通常,数据是异构的,因此并非所有图形始终以恒定模式相关。 如何确保不看空白卡片? (或任何其他在某些时候没有足够信息的图)

此示例基于iplocation命令,该命令通过IP地址给出纬度和经度,然后将其映射。 但是,如果突然我们的搜索基于“灰色” IP地址,例如127.0.0.1,则该团队将不会给我们结果,因此地图上将没有任何内容。
为了不看空卡,代币将被救出。
我们强加这样一个条件:如果lat字段(纬度)的值为空,则将没有标记,并且如果存在该值,则将标记设置为某个值。
<search id="map_search"> <query> | makeresults | eval ipaddr="$ipaddr$" | iplocation ipaddr </query> <progress> <condition match='$result.lat$!=""'> <set token="show_map">true</set> </condition> <condition> <unset token="show_map"></unset> </condition> </progress> </search>
然后,我们建立带有卡的面板对此令牌的依赖性。
<panel depends="$show_map$"> <map> <title>The map shows up if geostats can determine lat and lon</title> <search base="map_search"> <query>geostats count by ipaddr</query> </search> </map> </panel>
这是发生了什么:


令牌是用于创建动态仪表板的非常强大的工具。 您可以
在此处阅读有关它们的更多信息
。3.引导程序
Bootstrap是用于创建网站和Web应用程序的一组免费工具。 包括用于排版,Web表单,按钮,标签,导航块和其他Web界面组件(包括JavaScript扩展)的HTML和CSS设计模板。
有了它,您可以开箱即用地为仪表板提供很多便利。 此外,Splunk本身将Bootstrap视为一种用于其仪表板的工具。
例如,使用模板,将一个对话框添加到我们的仪表板。

为此,我们将使用以下代码添加一个按钮,以弹出一个对话框:
<panel> <html> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal"> Launch demo modal </button> <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Modal title</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true"/> </button> </div> <div class="modal-body"> 204.107.141.22 is a San Francisco IP address. </div> <div class="modal-footer"> <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> </div> </div> </div> </div> </html> </panel>
您可以
通过链接在getbootstrap.com
上找到此代码。
请注意代码正确工作,并且元素显示在仪表板上,代码必须在面板内,并且还必须指出它是html。
<panel> <html> … </html> </panel>
除了对话框外,还有更多内容。 我们建议您仔细研究站点
getbootstrap.com和提供的所有工具。
4.静态来源
什么是静态来源? 这些是可以放置或应用在仪表板上的不同图片,图标,样式,脚本。
它们必须存储在文件系统中:
$SPLUNK_HOME/etc/apps/<your_app>/appserver/static/<your_resource>
也可以通过URL获得访问权限:
http://splunk_adress :splunk_port/static/app/<your_app>/<your_resource>
例如,在表标题中添加一个图标。

为此,您需要将面板标题转换为html并使用title标签,并使用image标签在其中添加图标。
<panel> <html> <h3 class="dashboard-element-title">IP Address Details <img src="/static/app/dashboard_tips/info.png"/> </h3> </html> <table> <search base="map_search"></search> </table> </panel>
您还可以将图片/图标,文本,代码等添加到空白面板:

<panel> <html> <p> <img src="/static/app/dashboard_tips/info.png"/> This image lives here on the file system: <code>$SPLUNK_HOME/etc/apps/APP_NAME/appserver/static</code> </p> </html> </panel>
5. Splunk风格指南

这是有关颜色,图标,字体大小等的指南,可用于Splunk仪表板,以免脱离整体设计。 元素可以作为类引用,并可以在其仪表板中使用。
您可以在以下网址找到样式指南:
http:// splunk_adress:splunk_port /en-US/static/docs/style/style-guide.html


让我们从“样式指南”中向控制台添加一个用户图标,以进一步更改其大小和颜色。

为此,我们使用以下代码:
<panel> <html> <p> Check it out: <br /> <i class="icon-user"></i> </p> <p> Change the font size: <br /><br /> <i class="icon-user" style="font-size:3em"></i> </p> <p> Change the color: <br /><br /> <i class="icon-user" style="font-size:3em; color: #5CC05C"></i> </p> </html> </panel>
在本文中,我们看了一些简单的示例,这些示例说明了如何在仪表板上配置动力学,如何在其中放置不同的元素,如何查找和添加不同的模板。 在下一篇文章中,我们将继续使用JavaScript实现更复杂的事情。
带有所示示例的应用程序可以在
GitHub上
找到 。
