{"id":20445796,"url":"https://github.com/rapid7/docker-logentries","last_synced_at":"2025-04-04T15:07:12.596Z","repository":{"id":26792392,"uuid":"30250789","full_name":"rapid7/docker-logentries","owner":"rapid7","description":"Forward all your Docker logs to logentries, like a breeze","archived":false,"fork":false,"pushed_at":"2024-11-06T09:22:41.000Z","size":238,"stargazers_count":108,"open_issues_count":20,"forks_count":58,"subscribers_count":66,"default_branch":"master","last_synced_at":"2025-03-28T14:06:01.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rapid7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-03T15:54:00.000Z","updated_at":"2024-11-06T09:22:46.000Z","dependencies_parsed_at":"2023-10-04T17:18:29.826Z","dependency_job_id":"c707300b-954c-45c8-97ac-2d55f0d9e734","html_url":"https://github.com/rapid7/docker-logentries","commit_stats":null,"previous_names":["nearform/docker-logentries"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fdocker-logentries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fdocker-logentries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fdocker-logentries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rapid7%2Fdocker-logentries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rapid7","download_url":"https://codeload.github.com/rapid7/docker-logentries/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247172490,"owners_count":20895866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T10:14:17.425Z","updated_at":"2025-04-04T15:07:12.578Z","avatar_url":"https://github.com/rapid7.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using InsightOps?\nPlease use our updated [library](https://github.com/rapid7/r7insight_docker) which supports specifying the region to send your log data to.\n\n# docker-logentries\n\nForward all your logs to [Logentries](https://logentries.com), like a breeze.\n\n![logentries dashboard](https://raw.githubusercontent.com/nearform/docker-logentries/master/dashboard.png)\n\nSee the Logentries community pack at [http://revelops.com/community/packs/docker/](http://revelops.com/community/packs/docker/).\n\n## Usage as a Container\n\nThe simplest way to forward all your container's log to Logentries is to\nrun this repository as a container, with:\n\n```sh\ndocker run -v /var/run/docker.sock:/var/run/docker.sock \\\n           --read-only \\\n           --security-opt=no-new-privileges \\\n           logentries/docker-logentries \\\n           -t \u003cTOKEN\u003e \\\n           -j \\\n           -a host=`uname -n`\n```\n\nYou can also use different tokens for logging, stats and events:\n```sh\ndocker run -v /var/run/docker.sock:/var/run/docker.sock \\\n           --read-only \\\n           --security-opt=no-new-privileges \\\n           logentries/docker-logentries \\\n           -l \u003cLOGSTOKEN\u003e \\\n           -k \u003cSTATSTOKEN\u003e \\\n           -e \u003cEVENTSTOKEN\u003e \\\n           -j \\\n           -a host=`uname -n`\n```\n\nThe `--read-only` docker flag specifies that the container file system will be read-only.\nThis is not a requirement but since currently there's no need for writing, it makes the container more secure.\n\nThe `--security-opt=no-new-privileges` docker flag sets a kernel bit which stops the process or its children\nfrom gaining additional privileges via setuid or sgid.  \nOnce again not required, but increases security.\n\nYou can pass the `--no-stats` flag if you do not want stats to be\npublished to Logentries every second. You __need this flag for Docker\nversion \u003c 1.5__.\n\nYou can pass the `--no-logs` flag if you do not want logs to be published to Logentries.\n\nYou can pass the `--no-dockerEvents` flag if you do not want events to be\npublished to Logentries.\n\nThe `-i/--statsinterval \u003cSTATSINTERVAL\u003e` downsamples the logs sent to Logentries. It collects samples and averages them before sending to Logentries.\n\nIf you don't use `-a` a default ``host=`uname -n` `` value will be added.\n\nYou can also filter the containers for which the logs/stats are\nforwarded with:\n\n* `--matchByName REGEXP`: forward logs/stats only for the containers whose name matches the given REGEXP.\n* `--matchByImage REGEXP`: forward logs/stats only for the containers whose image matches the given REGEXP.\n* `--skipByName REGEXP`: do not forward logs/stats for the containers whose name matches the given REGEXP.\n* `--skipByImage REGEXP`: do not forward logs/stats for the containers whose image matches the given REGEXP.\n\n### Running container in a restricted environment.\nSome environments(such as Google Compute Engine) does not allow to access the docker socket without special privileges. You will get EACCES(`Error: read EACCES`) error if you try to run the container.\nTo run the container in such environments add --privileged to the `docker run` command.\n\nExample:\n```sh\ndocker run --privileged \\\n           -v /var/run/docker.sock:/var/run/docker.sock \\\n           --read-only \\\n           --security-opt=no-new-privileges \\\n           logentries/docker-logentries \\\n           -t \u003cTOKEN\u003e \\\n           -j \\\n           -a host=`uname -n`\n```\n\n## Usage as a CLI\n\n1. `npm install docker-logentries -g`\n2. `docker-logentries -t TOKEN -a host=\\`uname -n\\``\n3. ..there is no step 3\n\nYou can also pass the `-j` switch if you log in JSON format, like\n[bunyan](http://npm.im/bunyan).\n\nYou can pass the `--no-stats` flag if you do not want stats to be\npublished to Logentries every second.\n\nYou can pass the `--no-logs` flag if you do not want logs to be published to Logentries.\n\nYou can pass the `--no-dockerEvents` flag if you do not want events to be\npublished to Logentries.\n\nThe `-a/--add` flag allows to add fixed values to the data being\npublished. This follows the format 'name=value'.\n\nThe `-i/--statsinterval` downsamples the logs sent to Logentries. It collects samples and averages them before sending to Logentries.\n\nYou can also filter the containers for which the logs/stats are\nforwarded with:\n\n* `--matchByName REGEXP`: forward logs/stats only for the containers whose name matches the given REGEXP.\n* `--matchByImage REGEXP`: forward logs/stats only for the containers whose image matches the given REGEXP.\n* `--skipByName REGEXP`: do not forward logs/stats for the containers whose name matches the given REGEXP.\n* `--skipByImage REGEXP`: do not forward logs/stats for the containers whose image matches the given REGEXP.\n\n## Embedded usage\n\nInstall it with: `npm install docker-logentries --save`\n\nThen, in your JS file:\n\n```\nvar logentries = require('docker-logentries')({\n  json: false, // or true to parse lines as JSON\n  secure: true, // or false to connect over plain TCP\n  token: process.env.TOKEN, // logentries TOKEN\n  newline: true, // Split on newline delimited entries\n  stats: true, // disable stats if false\n  add: null, // an object whose properties will be added\n\n  // the following options limit the containers being matched\n  // so we can avoid catching logs for unwanted containers\n  matchByName: /hello/, // optional\n  matchByImage: /matteocollina/, //optional\n  skipByName: /.*pasteur.*/, //optional\n  skipByImage: /.*dockerfile.*/ //optional\n})\n\n// logentries is the source stream with all the\n// log lines\n\nsetTimeout(function() {\n  logentries.destroy()\n}, 5000)\n```\n\n## Building a docker repo from this repository\n\n### Using the plain docker file\nFirst clone this repository, then:\n\n```bash\ndocker build -t logentries .\n\ndocker run -v /var/run/docker.sock:/var/run/docker.sock \\\n           --read-only \\\n           --security-opt=no-new-privileges \\\n           logentries \\\n           -t \u003cTOKEN\u003e \\\n           -j \\\n           -a host=`uname -n`\n```\n### Using Make - the official nodejs onbuild image \n```bash\nexport BUILD_TYPE=node-onbuild\nmake build\nmake test\nmake tag\n```\n\n### Using Make - the alpine linx build (~42Mb)\n```bash\nexport BUILD_TYPE=alpine-node\nmake build\nmake test\nmake tag\n```\n\n### Pushing to your own repo\nAfter you've build, tested, tagged it locally\n```bash\nexport DOCKER_REGISTRY_PREFIX=you-dockerhub-user/yourimage-name\nmake push\n```\n\n## How it works\n\nThis module wraps four [Docker\nAPIs](https://docs.docker.com/reference/api/docker_remote_api_v1.17/):\n\n* `POST /containers/{id}/attach`, to fetch the logs\n* `GET /containers/{id}/stats`, to fetch the stats of the container\n* `GET /containers/json`, to detect the containers that are running when\n  this module starts\n* `GET /events`, to detect new containers that will start after the\n  module has started\n\nThis module wraps\n[docker-loghose](https://github.com/mcollina/docker-loghose) and\n[docker-stats](https://github.com/pelger/docker-stats) to fetch the logs\nand the stats as a never ending stream of data.\n\nAll the originating requests are wrapped in a\n[never-ending-stream](https://github.com/mcollina/never-ending-stream).\n\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Fdocker-logentries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frapid7%2Fdocker-logentries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frapid7%2Fdocker-logentries/lists"}