Created
January 3, 2019 11:03
-
-
Save ta1kt0me/b2746fd21d99b87b0421a57dcf2f1a39 to your computer and use it in GitHub Desktop.
put cloudwatch logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
source "https://rubygems.org" | |
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } | |
gem "aws-sdk-cloudwatchlogs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require "aws-sdk-cloudwatchlogs" | |
require "json" | |
loop { | |
data = { | |
user_id: Random.rand(100), | |
category: Random.rand(10), | |
value: Random.rand(1000) | |
} | |
client = Aws::CloudWatchLogs::Client.new region: 'ap-northeast-1' | |
stream = client.describe_log_streams( | |
log_group_name: "kinesis-test", | |
) | |
event = client.put_log_events( | |
log_group_name: "kinesis-test", | |
log_stream_name: "ruby", | |
log_events: [ | |
{ | |
timestamp: Time.now.to_i.to_s + "000", | |
message: data.to_json | |
} | |
], | |
sequence_token: stream[0][0].upload_sequence_token | |
) | |
p event | |
sleep 60 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment