0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Splunk JSONを後から入力する

Last updated at Posted at 2020-07-10

https://community.splunk.com/t5/Getting-Data-In/Why-is-the-null-value-in-a-JSON-event-not-being-parsed-properly/m-p/508466/highlight/true#M86507
を見てびっくりしたので。

やり方

no_makeresults.spl
index=_internal
| head 1
| fields _raw _time
| eval _raw ="{\"administrativeState\":\"Unlocked\",\"apGroupId\":\"7954abec-de25-4758-bb5e-0d87be2f0254\",\"approvedTime\":\"1435500193785\",\"clientCount\":\"0\",\"configState\":\"newConfig\",\"connectionState\":\"Disconnect\",\"countryCode\":\"XX\",\"cpId\":\"15e2811e-a24f-4570-bd58-8f18c7e6ed91\",\"description\":\"\",\"dpId\":\"\",\"externalIp\":\"xxx.xx.xx.xx\",\"externalPort\":\"55540\",\"ip\":\"xxx.xx.xx.xx\",\"ipType\":\"Static\",\"ipv6\":\"\",\"ipv6Type\":null,\"isCriticalAP\":\"false\",\"lastSeenTime\":1454078438291,\"latitude\":null,\"location\":\"XXXXXXXXX\",\"longitude\":null,\"mac\":\"F0:B0:52:3B:F2:10\",\"meshHop\":0,\"meshRole\":null,\"model\":\"T300\",\"name\":\"XXXXXXXXX\",\"provisionMethod\":\"Discovered\",\"provisionStage\":null,\"registrationState\":\"Approved\",\"serial\":\"491484101277\",\"uptime\":\"81630\",\"version\":\"3.1.1.0.349\",\"wifi24Channel\":2,\"wifi50Channel\":104,\"zoneId\":\"d41a3397-b859-42cd-9332-e308a48069b2\"}"

index=_internal | head 1 | fields _time _rawで入れ物を作って、そこにJSONを放り込むだけ。

これまでは| makeresultでやっていたので、どうしてもStatistics表示になっていたけど、これで、JSONからの展開を模擬しやすくなった。

_Show syntax highlighted_表示だと

赤: フィールド名
緑: 文字列
紫: 数字
橙: null値

になっている。 externalPortlastSeenTimeの色が違うのはそのせい。

まとめ

これまでは| makeresultsからやっていたけど、これからはこの手段でいこうと思う

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?