项目作者: WillAbides

项目描述 :
commands for piping json to Azure EventGrid, AWS EventBridge and Splunk
高级语言: Go
项目地址: git://github.com/WillAbides/piper.git
创建时间: 2020-12-23T22:24:54Z
项目社区:https://github.com/WillAbides/piper

开源协议:MIT License

下载


piper

ci

piper contains three commands for piping json to Azure EventGrid, AWS EventBridge and Splunk

Piper, Piper, the red, red worm

woke last night to the sound of the storm

her words were words I sailed upon

— Phish (from the song Piper)


eventbridge-pipe

Install

go get

  1. go get github.com/willabides/piper/cmd/eventbridge-pipe

bindown

Add a bindown dependency:

  1. $ bindown template-source add piper https://github.com/WillAbides/piper/releases/latest/download/bindown-templates.yml
  2. $ bindown dependency add eventbridge-pipe piper#eventbridge-pipe

Usage

  1. Usage: eventbridge-pipe --type=STRING --source=STRING
  2. eventbridge-pipe posts events to AWS EventBridge.
  3. example:
  4. $ AWS_ACCESS_KEY='AKIA****************'
  5. $ AWS_SECRET_KEY='shhh_this_is_a_secret'
  6. $ data="$(cat <<"EOF"
  7. {"action": "obj.add", "@timestamp": 1604953432032, "el_name": "foo", "doc_id": "asdf"}
  8. {"action": "obj.rem", "@timestamp": 1604953732032, "el_name": "bar", "doc_id": "fdsa"}
  9. EOF
  10. )"
  11. $ echo "$data" | \
  12. eventbridge-pipe -s 'test-source' -t 'jp:action' -b 'my-bus' -T 'jp:"@timestamp"' \
  13. -r 'jp:"el_name"'
  14. Learn about JMESPath syntax at https://jmespath.org
  15. Flags:
  16. -h, --help Show context-sensitive help.
  17. --region="us-east-1" The aws region to publish events to.
  18. -t, --type=STRING Value for the DetailType field. JMESPath
  19. expressions allowed with "jp:" prefix.
  20. -b, --event-bus=STRING Value for the "EventBusName" field.
  21. -r, --resource=RESOURCE,... An element for the list in the "Resources"
  22. array. JMESPath expressions allowed with "jp:"
  23. prefix.
  24. -s, --source=STRING Value for the "Source" field. JMESPath
  25. expressions allowed with "jp:" prefix.
  26. -T, --timestamp=STRING Value for the "Time" field converted from epoch
  27. milliseconds. JMESPath expressions allowed with
  28. "jp:" prefix.
  29. --batch-size=10 Number of events to send in a batch.
  30. --flush-interval=2000 Time in milliseconds to wait before sending a
  31. partial batch. Set to 0 to never send a partial
  32. batch.

eventgrid-pipe

Install

go get

  1. go get github.com/willabides/piper/cmd/eventgrid-pipe

bindown

Add a bindown dependency:

  1. $ bindown template-source add piper https://github.com/WillAbides/piper/releases/latest/download/bindown-templates.yml
  2. $ bindown dependency add eventgrid-pipe piper#eventgrid-pipe

Usage

  1. Usage: eventgrid-pipe --subject=STRING --type=STRING <topic-endpoint>
  2. eventgrid-pipe posts events to Azure Event Grid.
  3. example:
  4. $ topic_endpoint='https://mytopicendpoint.westus2-1.eventgrid.azure.net'
  5. $ topic_key='shhh_secret_topic_key'
  6. $ data="$(cat <<"EOF"
  7. {"action": "obj.add", "@timestamp": 1604953432032, "el_name": "foo", "doc_id": "asdf"}
  8. {"action": "obj.rem", "@timestamp": 1604953732032, "el_name": "bar", "doc_id": "fdsa"}
  9. EOF
  10. )"
  11. $ echo "$data" | \
  12. eventgrid-pipe "$topic_endpoint" \
  13. -H "aeg-sas-key: $topic_key" \
  14. -T 'jp:"@timestamp"' \
  15. -t 'audit-log' \
  16. -s 'jp:action' \
  17. -i 'jp:doc_id'
  18. Learn about JMESPath syntax at https://jmespath.org
  19. Arguments:
  20. <topic-endpoint> Endpoint for posting events
  21. Flags:
  22. -h, --help Show context-sensitive help.
  23. -i, --id=STRING Value for the "id" field. If unset, a uuid will
  24. be generated for each event. JMESPath expressions
  25. allowed with "jp:" prefix.
  26. -s, --subject=STRING Value for the "subject" field. JMESPath
  27. expressions allowed with "jp:" prefix.
  28. -t, --type=STRING Value for the "eventType" field. JMESPath
  29. expressions allowed with "jp:" prefix.
  30. -T, --timestamp="now" Value for the "eventTime" field converted from
  31. epoch milliseconds. If unset, the current system
  32. time will be used.JMESPath expressions allowed
  33. with "jp:" prefix.
  34. -H, --header=HEADER,... Header to sent with the request in the same
  35. format as curl. e.g. '-H "aeg-sas-key: $EVKEY"'
  36. --data-version="1.0" Value for the "dataVersion" field. JMESPath
  37. expressions allowed with "jp:" prefix.
  38. --batch-size=10 Number of events to send in a batch.
  39. --flush-interval=2000 Time in milliseconds to wait before sending a
  40. partial batch. Set to 0 to never send a partial
  41. batch.

splunk-pipe

Install

go get

  1. go get github.com/willabides/piper/cmd/splunk-pipe

bindown

Add a bindown dependency:

  1. $ bindown template-source add piper https://github.com/WillAbides/piper/releases/latest/download/bindown-templates.yml
  2. $ bindown dependency add splunk-pipe piper#splunk-pipe

Usage

  1. Usage: splunk-pipe <endpoint>
  2. splunk-pipe posts events to splunk.
  3. example:
  4. $ splunk_endpoint="http://localhost:8080"
  5. $ splunk_hec_token="shhh_secret_token"
  6. $ data="$(cat <<"EOF"
  7. {"action": "obj.add", "@timestamp": 1604953432032, "el_name": "foo", "doc_id": "asdf"}
  8. {"action": "obj.rem", "@timestamp": 1604953732032, "el_name": "bar", "doc_id": "fdsa"}
  9. EOF
  10. )"
  11. $ echo "$data" | \
  12. splunk-pipe "$splunk_endpoint" \
  13. -H "Authorization: Splunk $splunk_hec_token" \
  14. -T 'jp:"@timestamp"'
  15. Learn about JMESPath syntax at https://jmespath.org
  16. Arguments:
  17. <endpoint> Endpoint for posting events
  18. Flags:
  19. -h, --help Show context-sensitive help.
  20. -t, --sourcetype=STRING Value for the "sourcetype" field. JMESPath
  21. expressions allowed with "jp:" prefix.
  22. -s, --source=STRING Value for the "source" field. JMESPath
  23. expressions allowed with "jp:" prefix.
  24. -T, --timestamp=STRING Value for the "eventTime" field converted from
  25. epoch milliseconds. JMESPath expressions allowed
  26. with "jp:" prefix.
  27. -H, --header=HEADER,... Header to sent with the request in the same
  28. format as curl. e.g. '-H "Authorization: Splunk
  29. $HEC_KEY"'
  30. -h, --host=STRING Value for the "host" field. JMESPath expressions
  31. allowed with "jp:" prefix.
  32. --index=STRING Value for the "index" field. JMESPath expressions
  33. allowed with "jp:" prefix.
  34. --batch-size=10 Number of events to send in a batch.
  35. --flush-interval=2000 Time in milliseconds to wait before sending a
  36. partial batch. Set to 0 to never send a partial
  37. batch.