{"title":"Send metrics","description":"Export OpenTelemetry metrics to Altertable with an SDK or collector, then verify gauge, sum, and histogram data with SQL.","order":400,"askSuggestions":["Why is value empty for my histogram metrics?","How do I find the metrics for one service?"],"navigation":true,"body":{"code":"var Component=(()=>{var p=Object.create;var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),x=(n,e)=>{for(var r in e)s(n,r,{get:e[r],enumerable:!0})},c=(n,e,r,o)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let i of f(e))!y.call(n,i)&&i!==r&&s(n,i,{get:()=>e[i],enumerable:!(o=u(e,i))||o.enumerable});return n};var S=(n,e,r)=>(r=n!=null?p(g(n)):{},c(e||!n||!n.__esModule?s(r,\"default\",{value:n,enumerable:!0}):r,n)),w=n=>c(s({},\"__esModule\",{value:!0}),n);var d=v((b,a)=>{a.exports=_jsx_runtime});var T={};x(T,{default:()=>l,frontmatter:()=>D});var t=S(d()),D={title:\"Send metrics\",description:\"Export OpenTelemetry metrics to Altertable with an SDK or collector, then verify gauge, sum, and histogram data with SQL.\",order:400,askSuggestions:[\"Why is value empty for my histogram metrics?\",\"How do I find the metrics for one service?\"]};function h(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",p:\"p\",pre:\"pre\",...n.components},{DocsPreviewDocument:r,DocsPreviewSection:o}=e;return r||m(\"DocsPreviewDocument\",!0),o||m(\"DocsPreviewSection\",!0),(0,t.jsxs)(r,{anchors:\"send-metrics configure-the-exporter verify-the-data\",children:[(0,t.jsxs)(o,{sectionId:\"send-metrics\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,t.jsx)(e.h1,{id:\"send-metrics\",children:\"Send metrics\"}),`\n`,(0,t.jsx)(e.p,{children:\"Send metrics with an OpenTelemetry SDK or collector, then query them alongside logs, traces, and business data.\"}),`\n`]}),(0,t.jsxs)(o,{sectionId:\"configure-the-exporter\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,t.jsx)(e.h2,{id:\"configure-the-exporter\",children:\"Configure the exporter\"}),`\n`,(0,t.jsxs)(e.p,{children:[(0,t.jsx)(e.a,{href:\"/docs/opentelemetry/setup#1-configure-authentication\",children:\"Configure authentication\"}),\" with credentials from the environment that owns your OpenTelemetry catalog. Set the metrics exporter endpoint to \",(0,t.jsx)(e.code,{children:\"https://api.altertable.ai/v1/metrics\"}),\" and use OTLP/HTTP with protobuf or JSON encoding.\"]}),`\n`,(0,t.jsxs)(e.p,{children:[\"Use your language's \",(0,t.jsx)(e.a,{href:\"https://opentelemetry.io/docs/languages/\",children:\"OpenTelemetry metrics SDK\"}),\" or an existing collector to export gauge, sum, histogram, exponential histogram, or summary data. Set the \",(0,t.jsx)(e.code,{children:\"service.name\"}),\" resource attribute so you can find the service in SQL.\"]}),`\n`,(0,t.jsxs)(e.p,{children:[\"The \",(0,t.jsx)(e.a,{href:\"/docs/api-references/opentelemetry#post-v1-metrics\",children:\"API reference\"}),\" defines headers, payloads, and response statuses.\"]}),`\n`]}),(0,t.jsxs)(o,{sectionId:\"verify-the-data\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,t.jsx)(e.h2,{id:\"verify-the-data\",children:\"Verify the data\"}),`\n`,(0,t.jsx)(e.p,{children:\"Generate activity in the service, allow an export interval to pass, then run:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:\"language-sql\",children:`SELECT timestamp, service_name, metric_name, metric_type, value, count, sum\nFROM opentelemetry.main.metrics\nORDER BY timestamp DESC\nLIMIT 100;\n`})}),`\n`,(0,t.jsxs)(e.p,{children:[\"Confirm that the service, metric names, and timestamps match the activity you generated. \",(0,t.jsx)(e.code,{children:\"value\"}),\" applies to gauge and sum points; use \",(0,t.jsx)(e.code,{children:\"count\"}),\" and \",(0,t.jsx)(e.code,{children:\"sum\"}),\" for histogram and summary points.\"]}),`\n`,(0,t.jsxs)(e.p,{children:[\"For the underlying storage tables, see the \",(0,t.jsx)(e.a,{href:\"/docs/opentelemetry/data-model\",children:\"data model\"}),\".\"]})]})]})}function l(n={}){let{wrapper:e}=n.components||{};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(h,{...n})}):h(n)}function m(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return w(T);})();\n;return Component;"},"_id":"docs/opentelemetry/metrics.mdx","_raw":{"sourceFilePath":"docs/opentelemetry/metrics.mdx","sourceFileName":"metrics.mdx","sourceFileDir":"docs/opentelemetry","contentType":"mdx","flattenedPath":"docs/opentelemetry/metrics"},"type":"Docs","path":"/opentelemetry/metrics","level":2,"parent":"opentelemetry"}