{"id":13530418,"url":"https://github.com/jenkinsci/influxdb-plugin","last_synced_at":"2025-04-04T21:07:28.272Z","repository":{"id":37269793,"uuid":"63704367","full_name":"jenkinsci/influxdb-plugin","owner":"jenkinsci","description":"Jenkins plugin to send build metrics into InfluxDB","archived":false,"fork":false,"pushed_at":"2025-03-27T07:08:18.000Z","size":1026,"stargazers_count":56,"open_issues_count":3,"forks_count":80,"subscribers_count":8,"default_branch":"development","last_synced_at":"2025-03-28T20:08:42.895Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://plugins.jenkins.io/influxdb/","language":"Java","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/jenkinsci.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":"2016-07-19T15:09:07.000Z","updated_at":"2025-03-27T07:08:22.000Z","dependencies_parsed_at":"2023-12-12T07:23:53.413Z","dependency_job_id":"5644b5ec-dfe5-4b68-872f-3de09dfca2ea","html_url":"https://github.com/jenkinsci/influxdb-plugin","commit_stats":{"total_commits":579,"total_committers":55,"mean_commits":"10.527272727272727","dds":0.4196891191709845,"last_synced_commit":"6e97c1e7a57b4d0bceedc0072ada54439ba0205d"},"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Finfluxdb-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Finfluxdb-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Finfluxdb-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkinsci%2Finfluxdb-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenkinsci","download_url":"https://codeload.github.com/jenkinsci/influxdb-plugin/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249524,"owners_count":20908212,"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":["hacktoberfest"],"created_at":"2024-08-01T07:00:49.540Z","updated_at":"2025-04-04T21:07:28.250Z","avatar_url":"https://github.com/jenkinsci.png","language":"Java","funding_links":[],"categories":["Collecting data into InfluxDB","Java"],"sub_categories":["Plugins"],"readme":"# InfluxDB Plugin for Jenkins\n\n[![Jenkins Plugin](https://img.shields.io/jenkins/plugin/v/influxdb.svg)](https://plugins.jenkins.io/influxdb)\n[![Jenkins.io Build Status](https://ci.jenkins.io/buildStatus/icon?job=Plugins%2Finfluxdb-plugin%2Fmaster)](https://ci.jenkins.io/job/Plugins/job/influxdb-plugin/job/master/)\n[![Jenkins Plugin Installs](https://img.shields.io/jenkins/plugin/i/influxdb.svg?color=blue)](https://plugins.jenkins.io/influxdb)\n\n## Description\n\nCollects data from various other Jenkins plugins and sends metrics to InfluxDB. It's also\npossible to send custom data inside pipeline jobs.\n\n## Breaking Changes\n\nSupport for InfluxDB 1.7 and lower was dropped in plugin release 3.0.\n\nYou can find all breaking changes for each version in the [breaking changes documentation](doc/breaking_changes.md).\n\n## Configuration\n\n### Configuration as Code\n\nTo configure InfluxDB plugin in Jenkins add the following to `jenkins.yaml`:\n\n```yaml\nunclassified:\n  influxDbGlobalConfig:\n    targets:\n    - credentialsId: \"some_id\"\n      database: \"some_database\"\n      description: \"some description\"\n      exposeExceptions: true\n      globalListener: true\n      globalListenerFilter: \"some filter\"\n      jobScheduledTimeAsPointsTimestamp: true\n      retentionPolicy: \"some_policy\"\n      url: \"http://some/url\"\n      usingJenkinsProxy: true\n```\n\n\u003e :warning: Prior 3.0, `credentialsId` needs to swapped to `username` and `password`.\n\n### Via Jenkins UI\n\nCreate a database in InfluxDB and a user with access rights. In Jenkins,\ngo to *Manage Jenkins \\\u003e Configure System \\\u003e InfluxDB Targets* and click\n\"Add\". Provide the database information. The \"URL\" parameter requires\nthe whole URL of the InfluxDB database, including the `http(s)://` and the\ndatabase port. Also, provide the retention policy you want the data to\nbe stored in InfluxDB (e.g. `15m` or `2d`). By default, it is `infinite`.\nExceptions generated by the InfluxDB plugin can also be\nignored by deselecting the \"Expose Exceptions\" checkbox.\n\n\u003e :warning: When you are using InfluxDB 1.x targets, **leave the Organization blank**. InfluxDB 2.x\n\u003e uses organizations and buckets instead of databases and retention policies, so `organization` field is\n\u003e used as an identifier whether the target is InfluxDB 1.x or 2.x.\n\n![Jenkins Configuration](doc/img/jenkins-configuration.png)\n\nIn your job, select \"Publish build data to InfluxDB\" from the post-build\nactions.\n\n![Post build menu](doc/img/post-build-action.png)\n\n### Via Jenkins Pipeline\n\nFrom version 1.19 onwards, you can create and remove targets in pipelines directly.\n\n```\n// Get InfluxDB plugin descriptor (version \u003c 2.0)\ndef influxdb = Jenkins.instance.getDescriptorByType(jenkinsci.plugins.influxdb.DescriptorImpl)\n\n// version \u003e= 2.0\ndef influxdb = Jenkins.instance.getDescriptorByType(jenkinsci.plugins.influxdb.InfluxDbStep.DescriptorImpl)\n\n// Create target\ndef target = new jenkinsci.plugins.influxdb.models.Target()\n\n// Set target details\n\n// Mandatory fields\ntarget.description = 'my-new-target'\ntarget.url = 'http://influxdburl:8086'\n\n// Not supported \u003e= 3.0\ntarget.username = 'my-username'\n\n// version \u003c 2.0\ntarget.password = 'my-password'\n\n// version 2.0 to 2.6\ntarget.password = hudson.util.Secret.fromString('my-password')\n\n// Version \u003e= 3.0\ntarget.credentialsId = 'my-id'\n\ntarget.database = 'my-database'\n\n// Optional fields\ntarget.retentionPolicy = '1d'                    // default = 'autogen'\ntarget.jobScheduledTimeAsPointsTimestamp = true  // default = false\ntarget.exposeExceptions = true                   // default = true\ntarget.usingJenkinsProxy = true                  // default = false\n\n// Add a target by using the created target object\ninfluxdb.addTarget(target)\ninfluxdb.save()\n\n// Write stuff to InfluxDB\ninfluxDbPublisher(selectedTarget: 'my-new-target')\n\n// Remove a target by using the target description field value\ninfluxdb.removeTarget('my-new-target')\ninfluxdb.save()\n```\n\n### Credentials\n\n- InfluxDB 1.8 targets support only `Username with password`.\n- InfluxDB 2.x supports `Username with password` for basic authentication and `Secret Text` for authentication \ntoken authentication.\n\n## Usage\n\n### Global Listener\n\nWhen `globalListener` is set to `true` for a target in which no results were published during the build, it will automatically publish the result for this target when the build is completed.\n\nTo configure the global listener, you can use environment variables prefixed with `INFLUXDB_PLUGIN`. The following variables are supported and all correspond to an `influxDbPublisher` optional parameter.\n\n- `INFLUXDB_PLUGIN_CUSTOM_PROJECT_NAME` -\u003e `customProjectName`\n- `INFLUXDB_PLUGIN_CUSTOM_PREFIX` -\u003e `customPrefix`\n- `INFLUXDB_PLUGIN_CUSTOM_FIELDS` -\u003e `jenkinsEnvParameterField`\n- `INFLUXDB_PLUGIN_CUSTOM_TAGS` -\u003e `jenkinsEnvParameterTag`\n\n**_NOTE:_** The environment variables must be set on the final build object. If you are creating or updating these variables in a pipeline, you should make sure they are exported with an [EnvironmentContributingAction](https://javadoc.jenkins.io/hudson/model/EnvironmentContributingAction.html).\n\n### Freestyle Jobs\n\nSelect the InfluxDB target you wish to publish the data to.\n\n![Select Target](doc/img/select-influxdb-target.png)\n\nFrom the \"Advanced\" tab you can choose to set a custom prefix for your `project_name` field,\na custom project name to be used instead of the default job name, custom fields for your\n`jenkins_data` metric, and custom tags for your all your metrics.\n\n![Advanced Options](doc/img/advanced-options.png)\n\n### Pipelines\n\nThe plugin can be used by calling either the `influxDbPublisher()` or the `step()` function.\n\n**_NOTE:_** The `influxDbPublisher()` function is only supported from version 1.21 onwards.\n\n**Pipeline syntax**\n\nThe only mandatory parameter is `selectedTarget`, which is the \"Description\" for your\ntarget in the global configuration.\n\n``` syntaxhighlighter-pre\ninfluxDbPublisher(selectedTarget: 'my-target')\n```\n\n``` syntaxhighlighter-pre\nstep([$class: 'InfluxDbPublisher', selectedTarget: 'my-target'])\n```\n\nOptional parameters\n\n- `customProjectName` (String) - custom project name\n- `customPrefix` (String) - custom prefix for project name\n- `customData` (Map) - custom fields in \"jenkins_custom_data\" measurement\n- `customDataTags` (Map) - custom tags in \"jenkins_custom_data\" measurement\n- `customDataMap` (Map) - custom fields in custom measurements\n- `customDataMapTags` (Map\u003cMap\u003e) - custom tags in custom measurements (map of tags for each custom measurements)\n- `jenkinsEnvParameterField` (String) - custom fields in \"jenkins_data\" measurement (newline-separated KEY=VALUE pairs)\n- `jenkinsEnvParameterTag` (String) - custom tags in all measurements (newline-separated KEY=VALUE pairs)\n- `measurementName` (String) - custom measurement name (replaces default \"jenkins_data\" and \"jenkins_custom_data\")\n\nAll `customData*` parameters contain custom data generated during the\nbuild and not by the plugin, so they are not available in the snippet generator.\n\n\n\u003e :heavy_exclamation_mark: NOTE! Up to release 1.10.3, pipeline was configured with using the url and database.\n\u003e\n\u003e``` syntaxhighlighter-pre\n\u003estep([$class: 'InfluxDbPublisher',\n\u003e        target: 'http://127.0.0.1:8086,jenkins_db',\n\u003e        ...\n\u003e    ])\n\u003e```\n\u003e This form of configuration is not supported from version 1.11 onwards.\n\nPipelines don't have post-build actions, so the build result, build\nordinal, and the build success boolean will default to `\"?\"`, `5`,\nand `false` respectively, unless set manually before calling `InfluxDbPublisher`.\nOnly the build result needs to be set manually, as the boolean value and ordinal are set\nbased on build result. Also, the build status will appear as `\"?\"` and the build\nduration might be a little off, because the build is not actually finished.\nIf you want to get those pieces of information you need to configure the plugin\nseparately on each job as a post-build action. The jobs can be run with,\nfor example, the [Build Pipeline Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Build+Pipeline+Plugin)\nto get data from all jobs to InfluxDB. Alternatively, you can insert the\ninformation in your build manually inside your Groovy script.\n\n``` syntaxhighlighter-pre\ntry {\n    // Build things here\n    if (currentBuild.result == null) {\n        currentBuild.result = 'SUCCESS' // sets the ordinal as 0 and boolean to true\n    }\n} catch (err) {\n    if (currentBuild.result == null) {\n        currentBuild.result = 'FAILURE' // sets the ordinal as 4 and boolean to false\n    }\n    throw err\n} finally {\n    influxDbPublisher(selectedTarget: 'my-target')\n}\n```\n\n## Custom Data\n\nYou can write custom data to InfluxDB like this:\n\n```\ndef myFields = [:]\nmyFields['field_a'] = 11\nmyFields['field_b'] = 12\ninfluxDbPublisher(selectedTarget: 'my-target', customData: myFields)\n```\n\nThis adds the fields `field_a` and `field_b` with values `11` and `12` respectively to a measurement called `jenkins_custom_data`.\n\nYou can also add tags to this measurement with the `customDataTags` parameter.\n\nAlternatively, you can write custom data to InfluxDB with a higher degree of customization like this:\n\n```\ndef myFields1 = [:]\ndef myFields2 = [:]\ndef myCustomMeasurementFields = [:]\nmyFields1['field_a'] = 11\nmyFields1['field_b'] = 12\nmyFields2['field_c'] = 21\nmyFields2['field_d'] = 22\nmyCustomMeasurementFields['series_1'] = myFields1\nmyCustomMeasurementFields['series_2'] = myFields2\nmyTags = ['series_1':['tag_a':'a','tag_b':'b'],'series_2':['tag_c':'c','tag_d':'d']]\ninfluxDbPublisher(selectedTarget: 'my-target', customDataMap: myCustomMeasurementFields, customDataMapTags: myTags)\n```\n\nThis creates 2 measurements, `series_1` and `series_2`.\nIt adds the fields `field_a` and `field_b` with values `11` and `12` respectively to measurement `series_1`.\nIt adds the fields `field_c` and `field_d` with values `21` and `22` respectively to measurement `series_2`.\n\nYou can also add tags to your custom measurements with the `customDataMapTags` parameter.\nYou **must** use the same map keys as measurement names as in `customDataMap`.\n\n\n## Supported Metrics\n\nSee all available metrics from the [available metrics documentation](doc/available_metrics.md).\n\n## Contribution\n\nCreate a pull request to the `development` branch.\n**No pull requests are merged directly to `master`**.\nComment your changes sufficiently and create appropriate tests.\n\nFor feature requests and bug reports,\nplease use the [Jenkins issue tracker](https://issues.jenkins-ci.org/issues/?jql=project%20%3D%20JENKINS%20AND%20component%20%3D%20influxdb-plugin).\n\n## Acknowledgements\n\nThis plugin was inspired by [Jouni Rajala](https://github.com/jrajala-eficode/jenkins-ci.influxdb-plugin)\nand [Christoph Burmeister](http://christoph-burmeister.eu/?p=2906).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Finfluxdb-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenkinsci%2Finfluxdb-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkinsci%2Finfluxdb-plugin/lists"}