-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impl Logger AddContext summand #162
Merged
Merged
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
97cf2aa
add katip-es deps
IvantheTricourne cc47cd5
wip es scribe/logger
IvantheTricourne 0c9ad23
Merge branch 'master' of github.com:f-o-a-m/hs-abci into es-scribe-lo…
IvantheTricourne 82741df
add metrics instructions
IvantheTricourne 42c2e7f
toggle response/request logs to ES or console
IvantheTricourne fa171e6
add some comments and rename app logger middleware for clarity
IvantheTricourne 598680d
some code cleanup
IvantheTricourne b5ba744
wip
martyall 1140afb
wip almost builds
IvantheTricourne b29682e
builds
IvantheTricourne 1623d9b
config verbosity levels
IvantheTricourne 1ba4a35
add addContext summand
IvantheTricourne 7297235
stylish
IvantheTricourne 2d4cfaa
use addContext in nameservice
IvantheTricourne 572d067
add datadog logs and elk installation instructions
IvantheTricourne 70cd67a
es
IvantheTricourne e0f139a
add contextevent type to add event type field for logs
IvantheTricourne 107659a
use local namespace in res/req middleware
IvantheTricourne 5f3f232
test image
IvantheTricourne 9cb37c7
update readme
IvantheTricourne c0c28e6
adjust vertical screenshots
IvantheTricourne 32187a1
use different images
IvantheTricourne 2de83c4
change image links to master branch
IvantheTricourne 8d12125
add image for creating a filter in kibana discovery
IvantheTricourne 154f349
use third person
IvantheTricourne e65dbf5
Merge branch 'master' of github.com:f-o-a-m/hs-abci into context-summand
IvantheTricourne 69a2d3d
add default select method
IvantheTricourne 69aefae
rm unused imports
IvantheTricourne 93d9cd7
use ContextEvent in token and nameservice modules
IvantheTricourne ec0add4
move context event to events
IvantheTricourne efd3757
Merge branch 'master' of github.com:f-o-a-m/hs-abci into context-summand
IvantheTricourne 94c9dff
Add logEvent and emitAndLogEvent
IvantheTricourne a1ae399
Switch logEvent to info
IvantheTricourne 2900ca3
Remove event_type logItem from resp/req loggers
IvantheTricourne 6a12cba
remove emitAndLogEvent
IvantheTricourne 130390f
Merge branch 'master' into context-summand
IvantheTricourne 896b581
stylish
IvantheTricourne 20cf9f0
Merge branch 'master' into context-summand
IvantheTricourne 87bfcf1
stylish
IvantheTricourne 1024c1c
Add TxEff constraint to token router
IvantheTricourne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,147 @@ | ||
# nameservice | ||
|
||
## Metrics | ||
## Metrics via Prometheus | ||
|
||
Run `nameservice` via the `Makefile`: | ||
|
||
``` | ||
make deploy-nameservice-local | ||
``` | ||
|
||
Along with running `nameservice`, this also starts a Prometheus] metrics server. | ||
Along with running `nameservice`, this command also starts a Prometheus metrics server. | ||
By default, the metrics server runs on `localhost:9200`. To use a different port, | ||
set the `STATS_PORT` environment variable to the desired port value. | ||
|
||
To see these metrics in Datadog, follow the | ||
[Prometheus host config instructions](https://docs.datadoghq.com/getting_started/integrations/prometheus/?tab=host#pagetitle) | ||
to configure a local Datadog agent to scrape the endpoint. | ||
to configure a local Datadog agent to scrape the endpoint. At minimum, to scrape all | ||
`nameservice` prometheus metrics, the appropriate `conf.yaml` (described above) should | ||
contain the following settings: | ||
|
||
```yaml | ||
init_config: | ||
|
||
instances: | ||
|
||
- prometheus_url: http://localhost:9200/metrics | ||
## namespace option prefixes all metric names in datadog | ||
namespace: prometheus | ||
## metrics names used in the nameservice app | ||
metrics: | ||
- count_buy | ||
- count_set | ||
- count_delete | ||
- histogram_buy* | ||
- histogram_set* | ||
- histogram_delete* | ||
``` | ||
|
||
Alternatively, use the `docker-compose` command: | ||
|
||
``` | ||
make deploy-nameservice-docker | ||
``` | ||
|
||
Once the `nameservice` server is running, start a Tendermint node: | ||
|
||
```bash | ||
> tendermint init | ||
> tendermint node | ||
``` | ||
|
||
Then run the `nameservice` tests: | ||
|
||
```bash | ||
make test-nameservice | ||
``` | ||
|
||
Once the test run is completed, you should now be able to view metrics | ||
on [Datadog's metrics explorer](https://app.datadoghq.com/metric/explorer). | ||
Firstly, ensure that the prometheus server is populated with metrics by | ||
visiting `localhost:9200/metrics` in a browser. It should look something like this: | ||
|
||
``` | ||
# TYPE count_buy counter | ||
count_buy 4 | ||
# TYPE count_delete counter | ||
count_delete 1 | ||
# TYPE count_set counter | ||
count_set 2 | ||
# TYPE histogram_buy histogram | ||
histogram_buy_bucket{le="1.0e-4"} 0.0 | ||
... | ||
# TYPE histogram_delete histogram | ||
histogram_delete_bucket{le="1.0e-4"} 0.0 | ||
... | ||
# TYPE histogram_set histogram | ||
histogram_set_bucket{le="1.0e-4"} 0.0 | ||
... | ||
``` | ||
|
||
Now, in Datadog's metrics explorer, we can search for metrics | ||
prefixed with the `namespace` value (i.e., `prometheus`) set above: | ||
|
||
<img src="https://raw.githubusercontent.com/f-o-a-m/hs-abci/master/hs-abci-examples/nameservice/images/prometheus-metrics.png" width="50%"/> | ||
|
||
## Alternative Logging | ||
|
||
In addition to Prometheus metrics, the `nameservice` app includes options for | ||
logging to Elasticsearch (ES) and Datadog metrics logging. By default, the app | ||
logs everything to the console: | ||
|
||
``` | ||
[2019-12-20 16:19:27][nameservice.server][Info][local][PID 89617][ThreadId 21][type:info] Request Received | ||
[2019-12-20 16:19:27][nameservice.server][Info][local][PID 89617][ThreadId 21][message_type:info][response_time:2.6e-5][message_count:1] | ||
``` | ||
|
||
These logs include request/response info and some event and metric logging. | ||
|
||
Alternatively, the app is set up to log the same information to ES | ||
and Datadog by setting the following environment variables: | ||
|
||
```bash | ||
DD_API_KEY ## Datadog API key | ||
ES_HOST ## Elasticsearch server host | ||
ES_PORT ## Elasticsearch server port | ||
``` | ||
|
||
We recommend using the [ELK (v683) docker image](https://hub.docker.com/r/sebp/elk/tags) | ||
to run an ES server alongside a Kibana instance to search and filter incoming logs. | ||
|
||
```bash | ||
> docker pull sebp/elk:683 | ||
> docker run -p 5601:5601 -p 9201:9200 -p 5044:5044 -it --name elk sebp/elk:683 | ||
``` | ||
|
||
**NOTE:** This command remaps the `ES_PORT` value from `9200` to `9201` to avoid collision with | ||
the Prometheus server that `nameservice` runs by default. The Kibana instance runs on port `5601`. | ||
|
||
After both Kibana and ES are running, start `nameservice` and a Tendermint node | ||
via the commands: | ||
|
||
```bash | ||
> DD_API_KEY=<DD_API_KEY> ES_HOST=localhost ES_PORT=9201 make deploy-nameservice | ||
> tendermint init | ||
> tendermint node | ||
``` | ||
|
||
At this point, there should be no logs printed on the console. If a valid | ||
Datadog API Key is provided, metrics logs are available on | ||
[Datadog's log explorer](https://app.datadoghq.com/logs). | ||
|
||
<img src="https://raw.githubusercontent.com/f-o-a-m/hs-abci/master/hs-abci-examples/nameservice/images/logs-tab.png" width="25%"/> | ||
|
||
To view ES logs on Kibana, go to `Management` on the sidebar and create a Kibana index pattern for `nameservice`: | ||
|
||
<img src="https://raw.githubusercontent.com/f-o-a-m/hs-abci/master/hs-abci-examples/nameservice/images/kibana-management.png" width="25%"/> | ||
|
||
<img src="https://raw.githubusercontent.com/f-o-a-m/hs-abci/master/hs-abci-examples/nameservice/images/create-index.png" width="75%"/> | ||
|
||
Finally, under `Discover`, we can add filters to view specific logs: | ||
|
||
<img src="https://raw.githubusercontent.com/f-o-a-m/hs-abci/master/hs-abci-examples/nameservice/images/kibana-discover.png" width="25%"/> | ||
|
||
For example, after running `nameservice` tests, we can add a filter to see | ||
event logs for `NameClaimed`, `NameRemapped` and `NameDeleted`: | ||
|
||
<img src="https://raw.githubusercontent.com/f-o-a-m/hs-abci/master/hs-abci-examples/nameservice/images/create-filter.png" width="75%"/> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before commenting on any of this, is there any way to have kibana pull metrics from prometheus in the same way datadog does. This would be good to fix some confusing asymmetry between server metrics and application metrics, and would also be easier to explain that you can now use either Kibana or datadog to view anything you want, or both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I’ll investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@blinky3713
It seems MetricBeat is an option from the ELK folks that can scrape prometheus exporters and servers. Given we're already using ELK stack, this seems to be a pretty good option.
Similar to the datadog agent, it also has a docker-compose.