tech.guitarrapc.cóm

Technical updates

SumoLogicAPI の PowerShell Moduleを更新したので簡単に日本語で

少量の更新ですが、いろいろ整理しました。

利用できるfunction一覧です。

CommandType Name                                 ModuleName    
----------- ----                                 ----------    
Function    Get-PSSumoLogicApiCollector          PSSumoLogicAPI
Function    Get-PSSumoLogicApiCollectorSource    PSSumoLogicAPI
Function    Get-PSSumoLogicApiCredential         PSSumoLogicAPI
Function    New-PSSumoLogicApiCredential         PSSumoLogicAPI
Function    Remove-PSSumoLogicApiCollector       PSSumoLogicAPI
Function    Remove-PSSumoLogicApiCollectorSource PSSumoLogicAPI
Function    Set-PSSumoLogicApiCollectorSource    PSSumoLogicAPI

目次

できることはこれらです。

API認証

アクセスID認証

今のところは Basic認証です。さっきみたら、アクセスIDとかあったのでこれで認証できたらうれしいなぁとか。*1

Basic認証

認証保持

ユーザー名とパスワードを入力することで、ファイルに保持します。 作ったファイルにかかれているのは、暗号化されたパスワードで 復号は認証を作ったPCでのみ可能です。

Userパラメータを省略した場合、configで指定したユーザーがデフォルトでUserに入ります。

SYNTAX
    New-PSSumoLogicApiCredential [[-path] <string>] [[-User] <string>]  [<CommonParameters>]

認証再利用

作成した認証ファイルを読み込んで、パスワードを復号しPSCredentialを作ります。

configで指定したユーザーがデフォルトでUserに入ります。

Get-PSSumoLogicApiCredential

Collector

取得

Collector 情報を取得します。これないとGUIでとか死にます。

SYNTAX
    Get-PSSumoLogicApiCollector [[-Id] <int[]>] [[-Credential] <pscredential>] [[-Async]]  [<CommonParameters>]

CollectorId を指定することで、そのコレクターだけになるので処理が軽くなります。

Get-PSSumoLogicApiCollector -Id 111111

CollectorId を指定したときに -Async スイッチを使うと RunSpaceを使って各Collectorに対して非同期に取得します。対象Collectorが2個以上なら使うべきです。

Get-PSSumoLogicApiCollector -Id 111111 -Async

設定

新規コレクターは、インストーラが通信を取れたときに行うのでAPIにありません。 あるいは、Sumo.confで行います。

削除

-Id でCollectorIdを指定してください。((一度Collector消すとそのCollectorIdの過去データも消えるのでお気をつけて))

SYNTAX
    Remove-PSSumoLogicApiCollector [[-Id] <int[]>] [[-Credential] <pscredential>] [[-Async]]  [<CommonParameters>]

Source

取得

Collector で取得する Source の設定です。これないと一個一個確認とか無理です。

SYNTAX
    Get-PSSumoLogicApiCollectorSource [[-CollectorId] <int[]>] [[-Id] <int[]>] [[-Credential] <pscredential>] [[-Async]]  [<CommonParameters>]

CollectorId と SourceId を指定することで、対象が絞られ処理が軽くなります。

Get-PSSumoLogicApiCollectorSource -CollectorId 111111 -Id 123

CollectorId を指定したときに -Async スイッチを使うと RunSpaceを使って各Collectorに対して非同期に取得します。対象Collectorが2個以上なら使うべきです。

Get-PSSumoLogicApiCollectorSource -CollectorId 111111,111112,11113 -Async

設定

指定したCollectorId に Sourceを設定します。パラメータ多いですね。禿げます。

SYNTAX
    Set-PSSumoLogicApiCollectorSource 
        [[-Id] <int[]>]
        [-pathExpression] <string>]
        [-name] <string>]
        [-sourceType] <string> {LocalFile | RemoteFile | LocalWindowsEventLog | RemoteWindowsEventLog | Syslog | Script | Alert | AmazonS3 | HTTP}]
        [-category] <string>]
        [-description] <string>]
        [[-alive] <bool>]
        [[-states] <string>]
        [[-automaticDateParsing] <bool>]
        [[-timeZone] <string>]
        [[-multilineProcessingEnabled] <bool>]
        [[-Credential] <pscredential>]
        [[-Async]]
        [<CommonParameters>]

削除

指定したCollectorId の SourceIdを削除します。やり直し便利です。*2

SYNTAX
    Remove-PSSumoLogicApiCollectorSource [[-CollectorId] <int[]>] [[-Id] <int[]>] [[-Credential] <pscredential>] [[-Async]]  [<CommonParameters>]

おわり

ここまで書いて、あ、パイプラインサポートしておくかと思って実装しました。

が、テストしてて、あ、SumoせんせーのAPI応答自体が遅いしPowerShellのパイプラインって順次ストリーム処理だから Async意味ないしむしろ劇的に遅くなったので、ほげー。

しょんぼり

*1:API資料にないんですが

*2:一度でも対象のsource消すとそのsourceIdの過去データも消えるのでお気をつけて