Skip to content
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

Provide working MUP deployment template and guide #25

Merged
merged 5 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 55 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,73 @@
# APM

This project reduces the original Kadira APM to a single Meteor project.
Most of the original features are working (like Slack alerts), but there is still a lot of work.
Feel free to contribute!
This project reduces the original Kadira APM to a single Meteor project and includes template MUP configuration to let you deploy to any remote server.

## Running it
Most of the original features are working (like Slack alerts), but there is still a lot of work. Feel free to contribute!

A mongo replica set is required!
## Get up and running with MUP

```
cd apm
meteor npm i
meteor
```
The easiest way to get this server up and running is to use the recommended configuration with [MUP](https://github.com/zodern/meteor-up).

This opens the following ports:
### Setup steps

* UI: 3000
* RMA: 11011
* API: 7007
1) Clone this repo and run `meteor npm install`.

## Login
2) Copy [`mup-placeholder.js`](mup-placeholder.js) to `mup.js`. Replace the placeholder entries in the configuration with your configuration.

username: admin@admin.com
password: admin
3) Server configuration steps you need to verify prior to deployment:

## Meteor apm settings
`metricsLifetime` sets the maximum lifetime of the metrics. Old metrics are removed after each aggregation.
The default value is 604800000 (1000 * 60 * 60 * 24 * 7 ^= 7 days).
a) This setup was tested using a server with at least 512MB of RAM.

```
"metricsLifetime": 604800000
```
b) Allow public access to your server on the following ports: 22, 80, 443, 7007, 11011.

c) In order for SSL configuration to succeed, you must set setup your DNS to point to your server IP address prior to deployment. Make sure to point both `apm.YOUR_DOMAIN.com` and `apm-engine.YOUR_DOMAIN.com` to the same server IP address.

## Meteor client settings
4) Run `npm run mup-deploy`.

5) Visit your APM UI page at `https://apm.YOUR_DOMAIN.com`. Login with username `admin@admin.com`, password `admin`. **CHANGE YOUR PASSWORD FROM THIS DEFAULT**.

6) In the APM web UI, create a new app and pass the settings to your Meteor app:

`settings.json`
```
"kadira": {
"appId": "...",
"appSecret": "...",
{
...
"kadira": {
"appId": "YOUR_APM_APP_ID",
"appSecret": "YOUR_APM_APP_SECRET",
"options": {
"endpoint": "http://localhost:11011"
"endpoint": "https://apm-engine.YOUR_DOMAIN.com"
}
},
},
}
```

7) Re-deploy your Meteor app, and you should see data populating in your APM UI in seconds.

## Server Restarts

The custom nginx proxy configuration does not persist through a server restart. There is no current way to hook this into MUP easily, so you will need to run `npx mup deploy` again if you need to restart the server. This should not be a problem with normal operation.

## Meteor apm settings
[`metricsLifetime`](settings.json) sets the maximum lifetime of the metrics. Old metrics are removed after each aggregation. The default value is 604800000 (1000 * 60 * 60 * 24 * 7 ^= 7 days).

As a baseline, a current Meteor application with ~500 DAL uses 0.7 GB for 7 days of APM data.

## Configuration details:

If you want to do custom configuration and server setup, here are items to be aware of:

1) A mongo replica set is required. This is set up automatically for you when using the template MUP configuration script.

2) If you are not getting APM data and see a [No 'Access-Control-Allow-Origin' header is present](#14) console error in your Meteor app, this is due to incorrect nginx proxy configuration. To confirm the issue, ssh into your server (`npx mup ssh`) and run `docker exec mup-nginx-proxy cat /etc/nginx/conf.d/default.conf`. Look for the upstream block for `apm-engine.YOUR_DOMAIN.com`, the entry should look like
```
upstream apm-engine.YOUR_DOMAIN.com {
# YOUR_APP
server SOME_IP:11011;
}
```

If you see port 80 for that setting, the MUP hook that tries to update this port may be failing.

## Changes to original Kadira

Expand All @@ -56,4 +81,4 @@ The default value is 604800000 (1000 * 60 * 60 * 24 * 7 ^= 7 days).
## ToDo

* Direct db access of alertsman (apm/server/alertsman/server.js) and remove api (apm/server/api/server.js)
* Replace invalid links to old kadira docs
* Replace invalid links to old kadira docs
61 changes: 61 additions & 0 deletions mup-placeholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copy this file to mup.js and replace placeholders with your info
module.exports = {
servers: {
one: {
host: 'YOUR_SERVER_IP',
username: 'ubuntu',
pem: '~/.ssh/id_rsa.YOUR_PRIVATE_SSH_KEY',
}
},

app: {
name: 'YOUR_APP-apm',
path: './apm',
servers: {
one: {},
},
buildOptions: {
serverOnly: true,
},
env: {
ROOT_URL: 'https://apm.YOUR_DOMAIN.com',
MONGO_URL: 'mongodb://localhost/meteor',
MONGO_OPLOG_URL: 'mongodb://mongodb/local'
},
docker: {
image: 'abernix/meteord:node-8.4.0-base',
args: [
'-p 11011:11011', // Open up the engine port
'--log-driver json-file', // Without these the Docker log file for Mongo will exhaust disk space
'--log-opt max-size=100m',
'--log-opt max-file=3',
],
},
enableUploadProgressBar: true,
},

proxy: {
domains: 'apm.YOUR_DOMAIN.com,apm-engine.YOUR_DOMAIN.com',
ssl: {
forceSSL: true,
letsEncryptEmail: 'contact@YOUR_DOMAIN.com',
},
},

mongo: {
version: '3.4.1',
servers: {
one: {},
},
},

hooks: {
// Using remoteCommand would be simpler here, but it was not working
'post.meteor.start'(api) {
return api.runSSHCommand(
api.getConfig().servers.one,
"docker exec mup-nginx-proxy sed -i '0,/server.*:80/ s/\\(server.*:\\)80/\\111011/1' /etc/nginx/conf.d/default.conf && docker exec mup-nginx-proxy nginx -s reload",
);
},
},
};
Loading