1"use strict";(self.webpackChunkig_website=self.webpackChunkig_website||[]).push([[6142],{9969:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>h,frontMatter:()=>l,metadata:()=>s,toc:()=>a});const s=JSON.parse('{"id":"gadget-devel/metadata","title":"Metadata file","description":"Introduction to the metadata file","source":"@site/versioned_docs/version-v0.54.1/gadget-devel/metadata.md","sourceDirName":"gadget-devel","slug":"/gadget-devel/metadata","permalink":"/docs/v0.54.1/gadget-devel/metadata","draft":false,"unlisted":false,"editUrl":"https://github.com/inspektor-gadget/inspektor-gadget/edit/main/versioned_docs/version-v0.54.1/gadget-devel/metadata.md","tags":[],"version":"v0.54.1","sidebarPosition":600,"frontMatter":{"title":"Metadata file","sidebar_position":600,"description":"Introduction to the metadata file"},"sidebar":"mainSidebar","previous":{"title":"Adding Metrics to your Gadget","permalink":"/docs/v0.54.1/gadget-devel/metrics"},"next":{"title":"Parameters","permalink":"/docs/v0.54.1/gadget-devel/parameters"}}');var d=i(74848),t=i(28453);const l={title:"Metadata file",sidebar_position:600,description:"Introduction to the metadata file"},o=void 0,c={},a=[{value:"Basic Contents",id:"basic-contents",level:3},{value:"Generating a metadata file",id:"generating-a-metadata-file",level:3},{value:"Datasources",id:"datasources",level:3},{value:"Annotations",id:"annotations",level:4},{value:"Datasource",id:"datasource",level:5},{value:"Field",id:"field",level:5}];function r(e){const n={a:"a",admonition:"admonition",code:"code",h3:"h3",h4:"h4",h5:"h5",li:"li",p:"p",pre:"pre",ul:"ul",...(0,t.R)(),...e.components};return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(n.p,{children:["The metadata file includes extra information about the gadget, like the name,\ndescription, etc. This file is o
1ptional. The metadata file has to be named\n",(0,d.jsx)(n.code,{children:"gadget.yaml"})," and placed in the root folder of the gadget."]}),"\n",(0,d.jsx)(n.h3,{id:"basic-contents",children:"Basic Contents"}),"\n",(0,d.jsxs)(n.p,{children:["The basic contents of the metadatafile are defined in\n",(0,d.jsx)(n.a,{href:"https://pkg.go.dev/github.com/inspektor-gadget/inspektor-gadget/pkg/metadata/v1#GadgetMetadata",children:"https://pkg.go.dev/github.com/inspektor-gadget/inspektor-gadget/pkg/metadata/v1#GadgetMetadata"}),"."]}),"\n",(0,d.jsx)(n.h3,{id:"generating-a-metadata-file",children:"Generating a metadata file"}),"\n",(0,d.jsxs)(n.p,{children:["It's possible to generate (and update) the metadata file for a gadget by using\nthe ",(0,d.jsx)(n.code,{children:"--update-metadata"})," flag when building it."]}),"\n",(0,d.jsx)(n.admonition,{type:"warning",children:(0,d.jsx)(n.p,{children:"We're considering changing how the metadata file is generated, so this support\ncould be changed soon."})}),"\n",(0,d.jsx)(n.h3,{id:"datasources",children:"Datasources"}),"\n",(0,d.jsxs)(n.p,{children:["The ",(0,d.jsx)(n.code,{children:"datasources"})," section in the metadata can be used to apply additional\ninformation to those. For example, ",(0,d.jsx)(n.code,{children:"annotations"})," can be applied to each\ndatasource to control different aspects of the datasource and how it's seen and\nused by operators. Additionally, ",(0,d.jsx)(n.code,{children:"fields"})," can also have their own ",(0,d.jsx)(n.code,{children:"annotations"}),",\nto control for example the formatting on a per-field level."]}),"\n",(0,d.jsxs)(n.p,{children:["For example, the following metadata file defines a ",(0,d.jsx)(n.code,{children:"foo"})," datasource with two\nfields, ",(0,d.jsx)(n.code,{children:"pid"})," and ",(0,d.jsx)(n.code,{children:"bar"}),". In this case, both the datasource and the fields have\nannotations:"]}),"\n",(0,d.jsx)(n.pre,{children:(0,d.jsx)(n.code,{className:"language-yaml",children:'datasources:\n foo:\n annotations:\n cli.clear-screen-before: "true"\n fields:\n pid:\n annotations:\n description: Process ID\n template: pid\n bar:\n annotations:\n description: Bar field description\n columns.hidden: true\n'})}),"\n",(0,d.jsx)(n.h4,{id:"annotations",children:"Annotations"}),"\n",(0,d.jsx)(n.h5,{id:"datasource",children:"Datasource"}),"\n",(0,d.jsxs)(n.p,{children:["The annotations for the datasource depend on its type and the operators it uses.\nFor more information, refer to the ",(0,d.jsx)(n.a,{href:"../spec/operators/",children:"operator documentation"}),"."]}),"\n",(0,d.jsx)(n.h5,{id:"field",children:"Field"}),"\n",(0,d.jsx)(n.p,{children:"The field annotations can be defined for each field of the datasource. The\nfollowing annotations are a non-exhaustive list of the available annotations:"}),"\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"description"}),": Column description"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"value.one-of"}),": Defines a list of possible values for this field."]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.width"}),": Width to reserve for this column"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.maxwidth"}),": Maximum width this column will be scaled to when using auto-scaling"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.minwidth"}),": MinWidth will be the minimum width this column will be scaled to when using auto-scaling"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.alignment"}),": Alignment of this column (left or right)"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.ellipsis"}),": EllipsisType defines how to abbreviate this column if the value needs more space than is available (start, middle, end)"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.hidden"}),": Hide the field from the columns output mode by default. The user can always show it by using ",(0,d.jsx)(n.code,{children:"--fields=bar,foo"}),"."]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.fixed"}),": Forces the Width even when using Auto-Scaling"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.hex"}),": Format the field using hexadecimal"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"template"}),": Use the annotation from some predefined templates. Available templates are:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:["timestamp:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.width: 35"}),", ",(0,d.jsx)(n.code,{children:"columns.maxwidth: 35"}),", ",(0,d.jsx)(n.code,{children:"columns.ellipsis: end"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["node:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.width: 30"}),", ",(0,d.jsx)(n.code,{children:"columns.ellipsis: middle"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["pod:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.width: 30"}),", ",(0,d.jsx)(n.code,{children:"columns.ellipsis: middle"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["container:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsx)(n.li,{children:(0,d.jsx)(n.code,{children:"columns.width: 30"})}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["namespace:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsx)(n.li,{children:(0,d.jsx)(n.code,{children:"columns.width: 30"})}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["containerImageName:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsx)(n.li,{children:(0,d.jsx)(n.code,{children:"columns.width: 30"})}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["containerImageDigest:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsx)(n.li,{children:(0,d.jsx)(n.code,{children:"columns.width: 30"})}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["containerStartedAt:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.hidden: true"}),", ",(0,d.jsx)(n.code,{children:"columns.width: 35"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["comm:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"description: Process name"}),", ",(0,d.jsx)(n.code,{children:"columns.maxwidth: 16"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["pcomm:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"description: The process name of the parent process"}),", ",(0,d.jsx)(n.code,{children:"columns.maxwidth: 16"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["pid:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.minwidth: 7"}),", ",(0,d.jsx)(n.code,{children:"columns.alignment: right"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["uid:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.minwidth: 8"}),", ",(0,d.jsx)(n.code,{children:"columns.alignment: right"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["gid:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.minwidth: 8"}),", ",(0,d.jsx)(n.code,{children:"columns.alignment: right"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["ns:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.hidden: true"}),", ",(0,d.jsx)(n.code,{children:"columns.width: 12"}),", ",(0,d.jsx)(n.code,{children:"columns.alignment: right"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["l4endpoint:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.minwidth: 22"}),", ",(0,d.jsx)(n.code,{children:"columns.width: 40"}),", ",(0,d.jsx)(n.code,{children:"columns.maxwidth: 52"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["syscall:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.width: 18"}),", ",(0,d.jsx)(n.code,{children:"columns.maxwidth: 28"})]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:["errorString:\n",(0,d.jsxs)(n.ul,{children:["\n",(0,d.jsx)(n.li,{children:(0,d.jsx)(n.code,{children:"columns.width: 12"})}),"\n"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"columns.replace"}),": Indicates this field must be replacing by the one on the annotation when printing it."]}),"\n",(0,d.jsxs)(n.li,{children:[(0,d.jsx)(n.code,{children:"json.skip"}),": Skip the field when marshalling to json."]}),"\n"]})]})}function h(e={}){const{wrapper:n}={...(0,t.R)(),...e.components};return n?(0,d.jsx)(n,{...e,children:(0,d.jsx)(r,{...e})}):r(e)}},28453:(e,n,i)=>{i.d(n,{R:()=>l,x:()=>o});var s=i(96540);const d={},t=s.createContext(d);function l(e){const n=s.useContext(t);return s.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(d):e.components||d:l(e.components),s.createElement(t.Provider,{value:n},e.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.