pghero_logs 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65b8346172beb9db1dc8c92894e2c281188180f9
4
- data.tar.gz: 95f8deb1a74898170a9bdfded9d6eafde7e014c3
3
+ metadata.gz: 8f8b5d851faf229e427810b291ef3a2068216d92
4
+ data.tar.gz: fb636212dda98475282259a8db5c41508157e0c6
5
5
  SHA512:
6
- metadata.gz: 21cb046acc333b356694468e1e62893ff67a7c019b9b691d926cb49bc76308e981be61ea85d2c7970da383109aa40953372a230f6442503babba66c80bd7ee09
7
- data.tar.gz: 7c3b0985cbd8da7b837ab4078dd16cb3896b0684f6889b77815cc35dbe2060785892e7dd98e1cb66199a8c91b4d82ab936cae2d9e4210b415ce406fbe1bf9ac8
6
+ metadata.gz: 705475d75a5d635b3b6c2f9884b20b1a2cc06c46d2a24b167cc374e887de6c267a85692537498d625cfb53cb22178e283035b198c4245410885c1308666b96a6
7
+ data.tar.gz: 7550be72e4b8b4f924c37236a438911c056b78f3d39be0e5f761e0355bd5b37ef8c811777c4793b772e0bcd64d4522628e57d5865abc9019013fdcc8bf57e7ae
data/README.md CHANGED
@@ -53,14 +53,26 @@ First, download the logs. Create an IAM user with the policy below
53
53
  And run
54
54
 
55
55
  ```sh
56
- export AWS_ACCESS_KEY_ID=test123
57
- export AWS_SECRET_ACCESS_KEY=secret123
58
- export AWS_DB_INSTANCE_IDENTIFIER=production
59
- pghero_logs download
56
+ aws configure
57
+ pghero_logs download <instance-id>
60
58
  ```
61
59
 
62
60
  Once logs are downloaded, run
63
61
 
64
62
  ```sh
65
- cat logs/postgresql.log.* | pghero_logs
63
+ cat postgresql.log* | pghero_logs
66
64
  ```
65
+
66
+ To analyze with [PgBadger](https://github.com/dalibo/pgbadger), install
67
+
68
+ ```sh
69
+ brew install pgbadger
70
+ ```
71
+
72
+ And run
73
+
74
+ ```sh
75
+ pgbadger --prefix "%t:%r:%u@%d:[%p]:" --outfile pgbadger.html postgresql.log* && open pgbadger.html
76
+ ```
77
+
78
+ Thanks to [RDS PgBadger](https://github.com/sportngin/rds-pgbadger) for the prefix.
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "pghero_logs"
4
- PgHeroLogs.run(ARGV[0])
4
+ PgHeroLogs.run(ARGV)
@@ -6,12 +6,13 @@ module PgHeroLogs
6
6
  class << self
7
7
  REGEX = /duration: (\d+\.\d+) ms execute <unnamed>: (.+)?/i
8
8
 
9
- def run(command)
9
+ def run(args)
10
+ command = args[0]
10
11
  case command
11
12
  when nil
12
13
  parse
13
14
  when "download"
14
- download
15
+ download args[1]
15
16
  else
16
17
  abort "Unknown command: #{command}"
17
18
  end
@@ -19,15 +20,13 @@ module PgHeroLogs
19
20
 
20
21
  protected
21
22
 
22
- def download
23
- Dir.mkdir("logs") if !Dir.exists?("logs")
24
-
25
- db_instance_identifier = ENV["AWS_DB_INSTANCE_IDENTIFIER"]
26
- rds = AWS::RDS.new(access_key_id: ENV["AWS_ACCESS_KEY_ID"], secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"])
23
+ def download(db_instance_identifier)
24
+ db_instance_identifier ||= ENV["AWS_DB_INSTANCE_IDENTIFIER"]
25
+ rds = AWS::RDS.new
27
26
  resp = rds.client.describe_db_log_files(db_instance_identifier: db_instance_identifier)
28
27
  files = resp[:describe_db_log_files].map{|f| f[:log_file_name] }
29
28
  files.each do |log_file_name|
30
- local_file_name = log_file_name.sub("error", "logs")
29
+ local_file_name = log_file_name.sub("error/", "")
31
30
  if File.exists?(local_file_name)
32
31
  puts "EXISTS #{local_file_name}"
33
32
  else
@@ -1,3 +1,3 @@
1
1
  module PgheroLogs
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pghero_logs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-14 00:00:00.000000000 Z
11
+ date: 2017-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg_query
@@ -103,9 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.4.5
106
+ rubygems_version: 2.6.11
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Slow query log parser for Postgres
110
110
  test_files: []
111
- has_rdoc: