PageSourceSearch

https://nbomber.com/assets/js/88b44eeb.86a82738.js

js nbomber.com collected 2026-10-02 06:24:19 UTC 8,995 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunknbomber_docs=globalThis.webpackChunknbomber_docs||[]).push([[2829],{4988(n,e,i){i.r(e),i.d(e,{assets:()=>l,contentTitle:()=>a,default:()=>d,frontMatter:()=>s,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"reporting/realtime/influx-db","title":"InfluxDB","description":"InfluxDB is an open-source time series database developed by the company InfluxData. It is used for storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics.","source":"@site/docs/reporting/realtime/influx-db.md","sourceDirName":"reporting/realtime","slug":"/reporting/realtime/influx-db","permalink":"/docs/reporting/realtime/influx-db","draft":false,"unlisted":false,"editUrl":"https://github.com/PragmaticFlow/NBomber.Docs/blob/dev/docs/reporting/realtime/influx-db.md","tags":[],"version":"current","sidebarPosition":4,"frontMatter":{"id":"influx-db","title":"InfluxDB","sidebar_position":4},"sidebar":"tutorialSidebar","previous":{"title":"Grafana","permalink":"/docs/reporting/realtime/grafana"},"next":{"title":"NBomber Studio","permalink":"/docs/reporting/realtime/nbomber_studio"}}');var r=i(4848),o=i(8453);const s={id:"influx-db",title:"InfluxDB",sidebar_position:4},a=void 0,l={},c=[{value:"Integrating with InfluxDB",id:"integrating-with-influxdb",level:2},{value:"Configuring InfluxDB Sink via JSON Config",id:"configuring-influxdb-sink-via-json-config",level:3},{value:"Saving custom metrics to InfluxDB",id:"saving-custom-metrics-to-influxdb",level:3},{value:"Working with InfluxDB v1 and v2",id:"working-with-influxdb-v1-and-v2",level:3}
1,{value:"Connecting to InfluxDB via code",id:"connecting-to-influxdb-via-code",level:3}];function u(n){const e={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",h3:"h3",img:"img",p:"p",pre:"pre",strong:"strong",...(0,o.R)(),...n.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.a,{href:"https://www.influxdata.com/",children:"InfluxDB"})," is an open-source time series database developed by the company InfluxData. It is used for storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics."]}),"\n",(0,r.jsxs)(e.p,{children:["Using ",(0,r.jsx)(e.a,{href:"/docs/nbomber/reporting-sinks",children:"Reporting Sinks"}),", you can store NBomber metrics into InfluxDb and analyze your performance results with ",(0,r.jsx)(e.a,{href:"https://docs.influxdata.com/influxdb/v2/visualize-data/",children:"InfluxDB UI"})," or ",(0,r.jsx)(e.a,{href:"https://grafana.com/",children:"Grafana"}),"."]}),"\n",(0,r.jsxs)(e.admonition,{type:"info",children:[(0,r.jsxs)(e.p,{children:["To start working with ",(0,r.jsx)(e.a,{href:"https://www.nuget.org/packages/NBomber.Sinks.InfluxDB",children:"NBomber.Sinks.InfluxDB"})," package you should install it:"]}),(0,r.jsxs)(e.p,{children:[(0,r.jsx)(e.a,{href:"https://github.com/PragmaticFlow/NBomber.Sinks.InfluxDB",children:(0,r.jsx)(e.img,{src:"https://github.com/PragmaticFlow/NBomber.Sinks.InfluxDB/actions/workflows/build.yml/badge.svg",alt:"build"})}),"\n",(0,r.jsx)(e.a,{href:"https://www.nuget.org/packages/NBomber.Sinks.InfluxDB/",children:(0,r.jsx)(e.img,{src:"https://img.shields.io/nuget/v/NBomber.Sinks.InfluxDB.svg",alt:"NuGet"})})]}),(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-code",children:"dotnet add package NBomber.Sinks.InfluxDB\n"})}),(0,r.jsxs)(e.p,{children:["Also, the ",(0,r.jsx)(e.a,{href:"https://github.com/PragmaticFlow/NBomber.Sinks.InfluxDB",children:"source code is available on Github"}),"."]})]}),"\n",(0,r.jsx)(e.h2,{id:"integrating-with-influxdb",children:"Integrating with InfluxDB"}),"\n",(0,r.jsx)(e.admonition,{type:"info",children:(0,r.jsxs)(e.p,{children:["The simple way to run InfluxDB is via Docker. By this link, you can find a ",(0,r.jsx)(e.a,{href:"https://github.com/PragmaticFlow/NBomber/blob/dev/examples/Demo/Features/RealtimeReporting/InfluxDB/docker-compose.yaml",children:"docker-compose.yaml"})," to run it."]})}),"\n",(0,r.jsx)(e.h3,{id:"configuring-influxdb-sink-via-json-config",children:"Configuring InfluxDB Sink via JSON Config"}),"\n",(0,r.jsxs)(e.p,{children:["To configure InfluxDB Sink we will use ",(0,r.jsx)(e.a,{href:"/docs/nbomber/json-config#json-infrastracture-config",children:"JSON Infrastracture Config"})," file"]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-json",metastring:'title="infra-config.json"',children:'{\n    "InfluxDBSink": {\n      "Url": "http://localhost:8086",\n      "Database": "nbomber",\n      "UserName": "username",\n      "Password": "password",      \n      "CustomTags": [{"Key": "environment", "Value": "linux"}]\n    }\n}\n'})}),"\n",(0,r.jsxs)(e.p,{children:["Now you should load this ",(0,r.jsx)(e.strong,{children:'"infra-config.json"'})," file."]}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-csharp",children:'var influxDbSink = new InfluxDBSink();\n\nvar scenario = Scenario.Create("scenario", async context => { ... });\n\nNBomberRunner\n    .RegisterScenarios(scenario)    \n    .WithReportingInterval(TimeSpan.FromSeconds(5))\n    .WithReportingSinks(influxDbSink)\n    // highlight-start\n    .LoadInfraConfig("infra-config.json");\n    // highlight-end\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsxs)(e.em,{children:["You can find the complete example by this ",(0,r.jsx)(e.a,{href:"https://github.com/PragmaticFlow/NBomber/tree/dev/examples/Demo/Features/RealtimeReporting/InfluxDB",children:"link"}),"."]})}),"\n",(0,r.jsx)(e.h3,{id:"saving-custom-metrics-to-influxdb",children:"Saving custom metrics to InfluxDB"}),"\n",(0,r.jsx)(e.p,{children:"There could be cases where you want to write your custom raw metrics to InfluxDB. Here is an example of how you can use InfluxDB sink to write your custom data."}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-csharp",children:'var influxDbSink = new InfluxDBSink();\n\nvar scenario = Scenario.Create("scenario", async context =>\n{    \n    var writeApi = influxDbSink.InfluxClient.GetWriteApiAsync();\n\n    var point = PointData\n        .Measurement("nbomber")\n        .Field("my_custom_counter", 1);\n\n    await writeApi.WritePointAsync(point);\n\n    return Response.Ok();\n});\n'})}),"\n",(0,r.jsx)(e.p,{children:(0,r.jsxs)(e.em,{children:["By following this link, you can get more info about ",(0,r.jsx)(e.a,{href:"https://github.com/influxdata/influxdb-client-csharp",children:"InfluxClient"}),"."]})}),"\n",(0,r.jsx)(e.h3,{id:"working-with-influxdb-v1-and-v2",children:"Working with InfluxDB v1 and v2"}),"\n",(0,r.jsx)(e.p,{children:"For InfluxDB v1:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-json",metastring:'title="infra-config.json"',children:'{\n    "InfluxDBSink": {\n      "Url": "http://localhost:8086",\n      "Database": "database",\n      "UserName": "username",\n      "Password": "password",      \n      "CustomTags": [{"Key": "environment", "Value": "linux"}]\n    }\n}\n'})}),"\n",(0,r.jsx)(e.p,{children:"For InfluxDB v2:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-json",metastring:'title="infra-config.json"',children:'{\n    "InfluxDBSink": {\n      "Url": "http://localhost:8086",\n      "Token": "Token",\n      "Org": "Org",\n      "Bucket": "nbomber",\n      "CustomTags": [{"Key": "environment", "Value": "linux"}]\n    }\n}\n'})}),"\n",(0,r.jsx)(e.h3,{id:"connecting-to-influxdb-via-code",children:"Connecting to InfluxDB via code"}),"\n",(0,r.jsx)(e.p,{children:"You might have a situation that requires you to connect to InfluxDB via code. For this, you can inject an instance of InfluxDBClient."}),"\n",(0,r.jsx)(e.p,{children:"For InfluxDB v1:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-csharp",children:'var influxDbSink = new InfluxDBSink(\n    new InfluxDBClient("http://localhost:8086", "username", "password", "database", retentionPolicy: "autogen")\n);\n'})}),"\n",(0,r.jsx)(e.p,{children:"For InfluxDB v2:"}),"\n",(0,r.jsx)(e.pre,{children:(0,r.jsx)(e.code,{className:"language-csharp",children:'var influxOpt = new InfluxDBClientOptions("http://localhost:8086");\ninfluxOpt.Org = "Org";\ninfluxOpt.Bucket = "nbomber";\ninfluxOpt.Token = "Token"\n\nvar influxDbSink = new InfluxDBSink(\n    new InfluxDBClient(influxOpt)\n);\n'})})]})}function d(n={}){const{wrapper:e}={...(0,o.R)(),...n.components};return e?(0,r.jsx)(e,{...n,children:(0,r.jsx)(u,{...n})}):u(n)}},8453(n,e,i){i.d(e,{R:()=>s,x:()=>a});var t=i(6540);const r={},o=t.createContext(r);function s(n){const e=t.useContext(o);return t.useMemo(function(){return"function"==typeof n?n(e):{...e,...n}},[e,n])}function a(n){let e;return e=n.disableParentContext?"function"==typeof n.components?n.components(r):n.components||r:s(n.components),t.createElement(o.Provider,{value:e},n.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.