eshero 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/app/controllers/es_hero/home_controller.rb +15 -0
- data/app/views/es_hero/home/index.html.erb +129 -0
- data/config/routes.rb +3 -0
- data/eshero.gemspec +25 -0
- data/lib/eshero.rb +33 -0
- data/lib/eshero/engine.rb +5 -0
- data/lib/eshero/version.rb +3 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1ef98fc455f66b88f2948dcc46b55038b59accd1
|
4
|
+
data.tar.gz: 8ba156a71a44edb8faddc9d3d4424f22ac2a1993
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 105b9e7928aaa2f81badbb37cd053d3977eefaf0f1d2afe2f16697c63bd8a00893fbfca51ba9c6faac461dbdaf9150a1ec430381ef123944f7c27866dde6dade
|
7
|
+
data.tar.gz: de349c587e3fff87b0b7e5dffbd931c17514b5dc593b82cc7d7b8dec3c27b2113387e901eb9a8ea3063e55c87e60f620bc4076d4341e7d383f7b9bb325db13c7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Andrew Kane
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# EsHero
|
2
|
+
|
3
|
+
Elasticsearch insights made easy
|
4
|
+
|
5
|
+
[View the demo](https://eshero.herokuapp.com/)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application’s Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'eshero'
|
13
|
+
```
|
14
|
+
|
15
|
+
And mount the dashboard in your `config/routes.rb`:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
mount EsHero::Engine, at: "eshero"
|
19
|
+
```
|
20
|
+
|
21
|
+
Be sure to [secure the dashboard](#security) in production.
|
22
|
+
|
23
|
+
## Insights
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
EsHero.indices
|
27
|
+
EsHero.nodes
|
28
|
+
```
|
29
|
+
|
30
|
+
## Security
|
31
|
+
|
32
|
+
#### Basic Authentication
|
33
|
+
|
34
|
+
Set the following variables in your environment or an initializer.
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
ENV["ESHERO_USERNAME"] = "andrew"
|
38
|
+
ENV["ESHERO_PASSWORD"] = "secret"
|
39
|
+
```
|
40
|
+
|
41
|
+
#### Devise
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
authenticate :user, lambda {|user| user.admin? } do
|
45
|
+
mount EsHero::Engine, at: "eshero"
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
## TODO
|
50
|
+
|
51
|
+
- status checks
|
52
|
+
- stats on memory and disk space
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Everyone is encouraged to help improve this project. Here are a few ways you can help:
|
57
|
+
|
58
|
+
- [Report bugs](https://github.com/ankane/eshero/issues)
|
59
|
+
- Fix bugs and [submit pull requests](https://github.com/ankane/eshero/pulls)
|
60
|
+
- Write, clarify, or fix documentation
|
61
|
+
- Suggest or add new features
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module EsHero
|
2
|
+
class HomeController < ActionController::Base
|
3
|
+
layout false
|
4
|
+
|
5
|
+
protect_from_forgery
|
6
|
+
|
7
|
+
http_basic_authenticate_with name: ENV["ESHERO_USERNAME"], password: ENV["ESHERO_PASSWORD"] if ENV["ESHERO_PASSWORD"]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@nodes = EsHero.nodes
|
11
|
+
@indices = EsHero.indices
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>EsHero</title>
|
5
|
+
|
6
|
+
<meta charset="utf-8" />
|
7
|
+
|
8
|
+
<style>
|
9
|
+
body {
|
10
|
+
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
11
|
+
margin: 0;
|
12
|
+
padding: 20px;
|
13
|
+
font-size: 14px;
|
14
|
+
line-height: 1.4;
|
15
|
+
color: #333;
|
16
|
+
background-color: #333;
|
17
|
+
}
|
18
|
+
|
19
|
+
a, a:visited, a:active {
|
20
|
+
color: #428bca;
|
21
|
+
text-decoration: none;
|
22
|
+
}
|
23
|
+
|
24
|
+
a:hover {
|
25
|
+
text-decoration: underline;
|
26
|
+
}
|
27
|
+
|
28
|
+
table {
|
29
|
+
width: 100%;
|
30
|
+
border-collapse: collapse;
|
31
|
+
border-spacing: 0;
|
32
|
+
margin-bottom: 20px;
|
33
|
+
}
|
34
|
+
|
35
|
+
th {
|
36
|
+
text-align: left;
|
37
|
+
border-bottom: solid 2px #ddd;
|
38
|
+
}
|
39
|
+
|
40
|
+
table td, table th {
|
41
|
+
padding: 8px;
|
42
|
+
}
|
43
|
+
|
44
|
+
td {
|
45
|
+
border-top: solid 1px #ddd;
|
46
|
+
}
|
47
|
+
|
48
|
+
.text-muted {
|
49
|
+
color: #999;
|
50
|
+
}
|
51
|
+
|
52
|
+
.container {
|
53
|
+
max-width: 800px;
|
54
|
+
margin-left: auto;
|
55
|
+
margin-right: auto;
|
56
|
+
}
|
57
|
+
|
58
|
+
.alert {
|
59
|
+
padding: 12px 20px;
|
60
|
+
color: #fff;
|
61
|
+
background-color: #9c6;
|
62
|
+
margin-bottom: 20px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.content {
|
66
|
+
padding: 20px 20px 1px 20px;
|
67
|
+
background-color: #eee;
|
68
|
+
margin-bottom: 20px;
|
69
|
+
}
|
70
|
+
|
71
|
+
h1 {
|
72
|
+
margin-top: 0;
|
73
|
+
font-size: 20px;
|
74
|
+
font-weight: bold;
|
75
|
+
}
|
76
|
+
|
77
|
+
h1, p {
|
78
|
+
margin-bottom: 20px;
|
79
|
+
}
|
80
|
+
</style>
|
81
|
+
</head>
|
82
|
+
<body>
|
83
|
+
<div class="container">
|
84
|
+
<div class="alert">EsHero</div>
|
85
|
+
<div class="content">
|
86
|
+
<h1>Nodes</h1>
|
87
|
+
<table>
|
88
|
+
<thead>
|
89
|
+
<tr>
|
90
|
+
<th>Node</th>
|
91
|
+
<th style="width: 20%;">CPU</th>
|
92
|
+
<th style="width: 20%;">Connections</th>
|
93
|
+
</tr>
|
94
|
+
</thead>
|
95
|
+
<tbody>
|
96
|
+
<% @nodes.each do |node| %>
|
97
|
+
<tr>
|
98
|
+
<td><%= node[:name] %></td>
|
99
|
+
<td><%= node[:cpu] %>%</td>
|
100
|
+
<td><%= node[:connections] %></td>
|
101
|
+
</tr>
|
102
|
+
<% end %>
|
103
|
+
</tbody>
|
104
|
+
</table>
|
105
|
+
</div>
|
106
|
+
<div class="content">
|
107
|
+
<h1>Indices</h1>
|
108
|
+
<table>
|
109
|
+
<thead>
|
110
|
+
<tr>
|
111
|
+
<th>Index</th>
|
112
|
+
<th style="width: 20%;">Documents</th>
|
113
|
+
<th style="width: 20%;">Size</th>
|
114
|
+
</tr>
|
115
|
+
</thead>
|
116
|
+
<tbody>
|
117
|
+
<% @indices.each do |index| %>
|
118
|
+
<tr>
|
119
|
+
<td><%= index[:name] %><br /><% if index[:aliases].any? %><span class="text-muted">aliased as <%= index[:aliases].join(", ") %></span><% else %> <% end %></td>
|
120
|
+
<td><%= number_with_delimiter(index[:docs]) %></td>
|
121
|
+
<td><%= number_to_human_size(index[:size]) %></td>
|
122
|
+
</tr>
|
123
|
+
<% end %>
|
124
|
+
</tbody>
|
125
|
+
</table>
|
126
|
+
</div>
|
127
|
+
</div>
|
128
|
+
</body>
|
129
|
+
</html>
|
data/config/routes.rb
ADDED
data/eshero.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eshero/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "eshero"
|
8
|
+
spec.version = EsHero::VERSION
|
9
|
+
spec.authors = ["Andrew Kane"]
|
10
|
+
spec.email = ["andrew@chartkick.com"]
|
11
|
+
spec.summary = %q{Elasticsearch insights made easy}
|
12
|
+
spec.description = %q{Elasticsearch insights made easy}
|
13
|
+
spec.homepage = "https://github.com/ankane/eshero"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "elasticsearch"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
data/lib/eshero.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require "eshero/version"
|
2
|
+
require "elasticsearch"
|
3
|
+
require "eshero/engine" if defined?(Rails)
|
4
|
+
|
5
|
+
module EsHero
|
6
|
+
|
7
|
+
def self.indices
|
8
|
+
aliases = client.indices.get_aliases
|
9
|
+
client.indices.stats["indices"].map do |name, info|
|
10
|
+
{
|
11
|
+
name: name,
|
12
|
+
docs: info["total"]["docs"]["count"],
|
13
|
+
size: info["total"]["store"]["size_in_bytes"],
|
14
|
+
aliases: (aliases[name]["aliases"] || {}).keys
|
15
|
+
}
|
16
|
+
end.sort_by{|index| [-index[:size], index[:name]] }
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.nodes
|
20
|
+
client.nodes.stats["nodes"].map do |name, info|
|
21
|
+
{
|
22
|
+
name: info["name"],
|
23
|
+
connections: info["http"]["current_open"],
|
24
|
+
cpu: info["os"]["cpu"]["usage"]
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.client
|
30
|
+
@client ||= Elasticsearch::Client.new(url: ENV["ESHERO_ELASTICSEARCH_URL"] || ENV["ELASTICSEARCH_URL"])
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eshero
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Kane
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: elasticsearch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Elasticsearch insights made easy
|
56
|
+
email:
|
57
|
+
- andrew@chartkick.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- app/controllers/es_hero/home_controller.rb
|
68
|
+
- app/views/es_hero/home/index.html.erb
|
69
|
+
- config/routes.rb
|
70
|
+
- eshero.gemspec
|
71
|
+
- lib/eshero.rb
|
72
|
+
- lib/eshero/engine.rb
|
73
|
+
- lib/eshero/version.rb
|
74
|
+
homepage: https://github.com/ankane/eshero
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.4.5
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Elasticsearch insights made easy
|
98
|
+
test_files: []
|