Running a own Kadira instance Update: now with a guide!

Oh I should mention that I deployed via Docker Cloud. For those wanting to do the same, I’ve added my Docker Cloud stack file below (docker-cloud.yml). If it matters, Docker Cloud provisioned the kadira-engine and kadira-ui containers on Digital Ocean and kadira-ui on AWS.

I’ve pushed my fixed version of the kadira-rma image to a public Docker repo here: dkoo761/kadira-rma. There’s a description there of exactly what I’ve changed from @vladgolubev’s version.

I got an error when trying to use a replica set URL as the MONGO_URL so I had to use a non-replica set URL. Also got an error when the entire MONGO_URL string was not wrapped in a string so I added quotes to fix that.

Here’s the instructions…

Deploying Kadira Server via Docker Cloud with stack file:

  1. save the following stack file to a local file called docker-cloud.yml:
kadira-engine:
  image: vladgolubev/kadira-engine
  autoredeploy: true
  deployment_strategy: high_availability
  environment:
    - "MONGO_URL=mongodb://user:pass@non-replica-hostname:port/dbname"
    - "MONGO_SHARD_URL_one=mongodb://user:pass@non-replica-hostname:port/dbname"
    - PORT=11011
  ports:
    - "11011:11011"
  restart: always

kadira-rma:
  image: dkoo761/kadira-rma
  autoredeploy: true
  deployment_strategy: high_availability
  environment:
    - "MONGO_URL=mongodb://user:pass@non-replica-hostname:port/dbname"
  restart: always

kadira-ui:
  image: vladgolubev/kadira-ui
  autoredeploy: true
  deployment_strategy: high_availability
  environment:
    - "MONGO_URL=mongodb://user:pass@non-replica-hostname:port/dbname"
    - "MONGO_SHARD_URL_one=mongodb://user:pass@non-replica-hostname:port/dbname"
  ports:
    - "4000:4000"
  restart: always
  1. in your docker-cloud.yml, change all instances of MONGO_URL and MONGO_SHARD_URL_one to your actual mongo URL from a cloud provider such as mLab or Compose. Be sure to use the “non-replica set” version of the URL.

  2. In Docker Cloud, click on Stacks, then Create, give your stack a name like “kadira-server”, then upload your docker-cloud.yml file.

  3. Click “Create and Deploy”

DONE!

1 Like

@speak2ravi I think your Node version and/or NPM version might be too old. Trying upgrading to newer versions. I ran it locally fine on node 5.2.0 and npm 3.3.12.

Hey guys, we got kadira up and running on a DO droplet using a local mongodb and nginx as a proxy. All processes are running, the ui is up and i can log in, create an app and use the connection string in my app to connect to it. All well so far. Here is the issue. The kadira ui does not show my data?!? It’s stuck on loading (see screenshot). I have verified that data is actually coming in by inspecting mongo directly. If anyone has an idea as to where I can start debugging any further, I would be very grateful.

UPDATE:

Here is the nginx config for kadira ui running under a subdomain https://kadira.XXX.com:

server_tokens off; # for security-by-obscurity: stop displaying nginx version
# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}
# HTTP
server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        include snippets/lets-encrypt.conf;

        # pass requests to Meteor
        location / {
            proxy_pass http://127.0.0.1:4000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade; #for websockets
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
        }
}
# HTTPS server
server {
    listen 443 default_server ssl http2; # we enable SPDY here
    server_name kadira.XXX.com; # this domain must match Common Name (CN) in the SSL certificate
    root html; # irrelevant
    index index.html; # irrelevant

    include snippets/ssl.conf;

    ssl_certificate /etc/letsencrypt/live/kadira.XXX.com/fullchain.pem; # full path to SSL certificate and CA certificate concatenated together
    ssl_certificate_key /etc/letsencrypt/live/kadira.XXX.com/privkey.pem; # full path to SSL key

    # config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
    # to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
    add_header Strict-Transport-Security "max-age=31536000;";
    # If your application is not compatible with IE <= 10, this will redirect visitors to a page advising a browser update
    # This works because IE 11 does not present itself as MSIE anymore
    if ($http_user_agent ~ "MSIE" ) {
        return 303 https://browser-update.org/update.html;
    }
    # pass all requests to Meteor
    location / {
        proxy_pass http://127.0.0.1:4000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade; # allow websockets
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header X-Forwarded-For $remote_addr; # preserve client IP
# this setting allows the browser to cache the application in a way compatible with Meteor
        # on every applicaiton update the name of CSS and JS file is different, so they can be cache infinitely (here: 30 days)
        # the root path (/) MUST NOT be cached
        if ($uri != '/') {
            expires 30d;
        }
    }
}

and the one for the kadira-engine running under the subdomain: https:kadiraengine.XXX.com:

# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}
# HTTPS server
server {
    listen 443 ssl http2; # we enable SPDY here
    server_name kadiraengine.XXX.com; # this domain must match Common Name (CN) in the SSL certificate
    root html; # irrelevant
    index index.html; # irrelevant

    include snippets/ssl.conf;

    ssl_certificate /etc/letsencrypt/live/kadira.XXX.com/fullchain.pem; # full path to SSL certificate and CA certificate concatenated together
    ssl_certificate_key /etc/letsencrypt/live/kadira.XXX.com/privkey.pem; # full path to SSL key

    # config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
    # to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
    add_header Strict-Transport-Security "max-age=31536000;";
    # If your application is not compatible with IE <= 10, this will redirect visitors to a page advising a browser update
    # This works because IE 11 does not present itself as MSIE anymore
    if ($http_user_agent ~ "MSIE" ) {
        return 303 https://browser-update.org/update.html;
    }
    # pass all requests to Meteor
    location / {
        proxy_pass http://127.0.0.1:11011;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade; # allow websockets
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header X-Forwarded-For $remote_addr; # preserve client IP
        # this setting allows the browser to cache the application in a way compatible with Meteor
        # on every applicaiton update the name of CSS and JS file is different, so they can be cache infinitely (here: 30 days)
        # the root path (/) MUST NOT be cached
        if ($uri != '/') {
            expires 30d;
        }
    }
}
2 Likes

@tomsp, is your NGNX redirecting to to Kadira-apm? BTW can you post the NGINX configuration?

Hey @juanp thanx for taking an interest. I updated my post with the nginx config. Does anything come to mind?

where do you setup the settings.json ?

Hmm, what kind of settings.json file are you thinking about?

The below settings.

“kadira”: {
“appId”: “<>”,
“appSecret”: “<>”,
“options”: {
“endpoint”:“http://ip:11011
}
},
I see the below when i try to access the engine. The UI is still not responding…
kadira-engine_1 | blocked due missing appId: /
kadira-engine_1 | blocked due missing appId: /favicon.ico

Ah! Yes, this is the meteor app settings, this can be run locally by using meteor --settings settings.json, or if you are using Heroku or similar, you have to put this inside the METEOR_SETTINGS. Here is a great guide for using the settings file:

https://themeteorchef.com/tutorials/making-use-of-settings-json

And obviously you have to input the correct appId and appSecret that you generate for your app in Kadira.

Hey all. Thank you for all the input here and the tutorial on setting up Kadira. I have successfully set up the kadira on digitalocean droplets. One $20/month droplet for the kadira app and primary mongodb replica (I use this plan because kadira consistently uses 66% ram on 2Gb), and another $5/month for secondary mongodb replica.

I have created a new user on Kadira and have set it to the business plan. However, here comes the problem, I am stuck at the settings page that gives me the appid and app secret. Kadira doesn’t give me the graphs page at all. Any idea of what may have gone wrong is appreciated.

Other pages should show up after you connected your application to the kadira instance and data starts flowing in.

You need to connect your meteor app properly as speak2ravi says. I had the same problem myself, and it was because of using the wrong ports in the endpoint URL in the settings.json configuration in meteor. (I used port 4000, but it is 11011)

Make sure that your Kadira instance is reachable on the same port, or you have the open them in the server firewall. (port 4000 and 11011 should be open)

I am still struggling with heavy data buildup in my MongoDB database, do someone have the same problem? I got to 500MB in just a few days. (not RAM, but storeage)

@vyvegard and @speak2ravi, thank you for the replies. I got it working!! I was foolishly pointing the endpoint to https:// instead of http://. Hence, the kadira-engine thought that I had never activated the appid and appsecret.

I have been running Kadira for about five hours and my disk space usage increased about 35mb. Projecting it out to 5 days, I should be using about 840mb. I will let you know how it goes in the next few days. I got a 20gb ssd droplet now. If things go weird, then I will setup a cron job to sweep the old entries on kadiraData as a temporary fix.

Some more math here:
To run the business plan for a month, Kadira will consume about 5gb of space. The default settings for business plan enables the backup lasting for three months. So one app requires 15gb on business plan. Although I found that the real-time data is way more useful than the backups, I do enjoy the added features in the business plan. As you can see, the data consumption is not financially reasonable on mLab. That’s why I used the droplets to host the mongoDBs. Now I wonder how much Arunoda spent per month for server costs.

I have looked at the kadiraData collection, and most of the documents have an expiration date of three months later. Perhaps we can look into reducing the data backup time for the business plan?

1 Like

I tried to find docker cloud but the term seems so general.

Where can I find docker cloud?

The URL for Docker Cloud is https://cloud.docker.com

Did you figure this out?

I got it working with Docker Cloud and NGINX in front. The ‘Access-Control-Allow-Origin’ issue was in fact that NGINX was listen on port 543 when the port open in AWS was 443!

###There any special mongo configuration to start the db service?

I start the default monodb configuration and I got the error:

echo $KADIRA_MONGO_URL
mongodb://mongoapm:27027
docker-compose ps
         Name                       Command               State                   Ports
------------------------------------------------------------------------------------------------------
mongoapm                 /entrypoint.sh mongod --sm ...   Up       27017/tcp, 0.0.0.0:27027->27027/tcp
user_kadira-engine_1   npm run start                    Exit 1
user_kadira-rma_1      npm run start                    Up
user_kadira-ui_1       su -c /usr/bin/entrypoint. ...   Exit 1
kadira-ui_1      | npm WARN package.json meteor-dev-bundle@0.0.0 No description
kadira-ui_1      | npm WARN package.json meteor-dev-bundle@0.0.0 No repository field.
kadira-ui_1      | npm WARN package.json meteor-dev-bundle@0.0.0 No README data
kadira-ui_1      | npm WARN package.json meteor-dev-bundle@0.0.0 No license field.
kadira-rma_1     |
kadira-rma_1     | > kadira-rma@1.0.0 start /app
kadira-rma_1     | > run-p -l run:**
kadira-rma_1     |
kadira-engine_1  | starting apm-engine on port 11011
kadira-engine_1  | DDONE
kadira-engine_1  | Error connecting to the Mongo Metrics Cluster
kadira-engine_1  |
kadira-engine_1  | /app/node_modules/mongodb/lib/mongo_client.js:338
kadira-engine_1  |           throw err
kadira-engine_1  |                 ^
kadira-engine_1  | MongoError: failed to connect to server [mongoapm:27027] on first connect [MongoError: connect ECONNREFUSED]
kadira-engine_1  |     at null.<anonymous> (/app/node_modules/mongodb/node_modules/mongodb-core/lib/topologies/server.js:328:35)
kadira-engine_1  |     at emit (events.js:107:17)
kadira-engine_1  |     at null.<anonymous> (/app/node_modules/mongodb/node_modules/mongodb-core/lib/connection/pool.js:274:12)
kadira-ui_1      | /home/meteor/www/bundle/programs/server/node_modules/fibers/future.js:313
kadira-ui_1      | 						throw(ex);
kadira-ui_1      | 						^
kadira-ui_1      | MongoError: failed to connect to server [mongoapm:27027] on first connect
kadira-ui_1      |     at Object.Future.wait (/home/meteor/www/bundle/programs/server/node_modules/fibers/future.js:449:15)
kadira-ui_1      |     at new MongoConnection (packages/mongo/mongo_driver.js:211:27)
kadira-ui_1      |     at new MongoInternals.RemoteCollectionDriver (packages/mongo/remote_collection_driver.js:4:16)

However mongo was up and running :frowning:

###This is the final config:

version: '2'

services:
  mongodb:
    image: mongo:latest
    container_name: "mongoapm"
    environment:
      - MONGO_DATA_DIR=/data/db
      - MONGO_LOG_DIR=/dev/null
    volumes:
      - ./data/db:/data/db
    ports:
        - "27027:27027"
    command: mongod --smallfiles --logpath=/dev/null # --quiet
  kadira-engine:
    image: vladgolubev/kadira-engine
    ports:
      - "11011:11011"
    environment:
      - PORT=11011
      - MONGO_URL=$KADIRA_MONGO_URL
      - MONGO_SHARD_URL_one=$KADIRA_MONGO_URL

  kadira-rma:
    image: vladgolubev/kadira-rma
    environment:
      - MONGO_URL=$KADIRA_MONGO_URL

  kadira-ui:
    image: vladgolubev/kadira-ui
    ports:
      - "4000:4000"
    environment:
      - MONGO_URL=$KADIRA_MONGO_URL
      - MONGO_SHARD_URL_one=$KADIRA_MONGO_URL
```

Hey, were you able to run Kadira connecting to local MongoDB successfully ? If so, please advise if there is any specific configuration needed for MongoDB when running locally ? (It would be great if you can share your steps when configuring MongoDB

I got my app to send data to a local mongodb, but the data never shows up in then kadira ui as I described in my post above. So in the end I’d say no I didn’t get it to work properly.