web-interface.assets.bb8c8232-9099.9b2b292086f3eed4211a.js Maven / Gradle / Ivy
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["bb8c8232-9099"],{Lpa6AnJn:(j,M,i)=>{i.d(M,{A:()=>b});var t=i("Z7aTuO5B"),T=i("ii0bleBb"),p=i.n(T),N=i("J6y4/h8P"),_=i("VPaD/Np4"),F=i.n(_),I=i("rIl5IEuP"),R=i("dsvqAVKU");const u=N.default.div`
display: flex;
flex-wrap: wrap;
.form-group {
margin: 0 15px 0 0;
}
`,l=(0,N.default)(I.Input)`
min-width: 400px;
`,a="placeholder",y=({id:C,title:A,type:L})=>t.createElement("option",{key:C,value:C},A," (",L,")"),v=(C,A)=>C.title.localeCompare(A.title),x=({input:{type:C,title:A}})=>t.createElement(l,{id:`${C}-select`,type:"select",disabled:!0},t.createElement("option",null,`${A} (${C})`)),S=({disabled:C,inputs:A,onLoadMessage:L,preselectedInputId:$,title:V})=>{const[U,Z]=(0,t.useState)($||a),z=(0,t.useCallback)(B=>Z(B.target.value),[]),w=(0,t.useCallback)(()=>L(U),[L,U]),K=(0,t.useMemo)(()=>A==null?void 0:A.get($),[A,$]);if(K)return t.createElement(u,null,t.createElement(x,{input:K}),t.createElement(I.Button,{bsStyle:"info",disabled:U===a,onClick:w},V));if(A){const B=A.sort(v).map(y);return t.createElement(u,null,t.createElement(l,{id:"placeholder-select",type:"select","aria-label":"server input select",value:U,onChange:z,placeholder:a},t.createElement("option",{value:a},"Select an Input"),B.toArray()),t.createElement(I.Button,{bsStyle:"info",disabled:C||U===a,onClick:w},V))}return t.createElement(R.A,null)};S.propTypes={inputs:T.object,title:T.string.isRequired,preselectedInputId:T.string,onLoadMessage:T.func,disabled:T.bool},S.defaultProps={inputs:_.Map(),onLoadMessage:()=>{},preselectedInputId:void 0,disabled:!1};const b=S},M1VnFrlv:(j,M,i)=>{i.d(M,{Vs:()=>X,l3:()=>ct,BS:()=>ut,eU:()=>ft,li:()=>dt,El:()=>Dt,n6:()=>gt,l$:()=>yt});var t=i("Z7aTuO5B"),T=i("ii0bleBb"),p=i.n(T),N=i("D4SbLiE/"),_=i.n(N),F=i("JnTtTRmZ"),I=i.n(F),R=i("J6y4/h8P"),u=i("QL8i6bcz"),l=i("rIl5IEuP"),a=i("IOI9nV80"),y=i("yEuO7gC5"),v=i("wToqYuKZ"),x=i("BqxuktKK"),S=i("MdYBRjRJ"),b=i("v4GbOr/o"),C=i("HCsT5Gmk");const A=(0,R.default)(l.Row)`
margin-bottom: 8px;
`,L=R.default.form`
display: flex;
gap: 0.25em;
`,$=_()({displayName:"CreateInputControl",propTypes:{sendTelemetry:p().func.isRequired,location:p().object.isRequired},mixins:[I().connect(v.P)],getInitialState(){return{selectedInput:void 0,selectedInputDefinition:void 0}},_formatSelectOptions(){let e=[];const{inputTypes:n}=this.state;return n?(e=Object.keys(n).map(o=>({value:o,label:n[o]})),e.sort((o,r)=>o.label.toLowerCase().localeCompare(r.label.toLowerCase()))):e.push({value:"none",label:"No inputs available",disabled:!0}),e},_onInputSelect(e){e===""&&this.setState(this.getInitialState()),this.setState({selectedInput:e}),this.props.sendTelemetry(b.g.INPUTS.INPUT_SELECTED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"input-select",event_details:{value:e}}),v.L.get.triggerPromise(e).then(n=>this.setState({selectedInputDefinition:n}))},_openModal(e){e.preventDefault();const{selectedInput:n}=this.state,s=u.d.exports("inputConfiguration").find(o=>o.type===n);if(s){const o=()=>this.setState({customInputsComponent:void 0}),r=s.component;this.setState({customInputsComponent:t.createElement(r,{onClose:o})})}this.configurationForm.open()},_createInput(e){this.props.sendTelemetry(b.g.INPUTS.INPUT_CREATED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"input-create"}),y.j.create(e).then(()=>{this.setState(this.getInitialState())})},render(){let e;const{selectedInputDefinition:n,selectedInput:s,inputTypes:o,customInputsComponent:r}=this.state;if(n&&!r){const c=o[s];e=t.createElement(X,{ref:d=>{this.configurationForm=d},key:"configuration-form-input",configFields:n.requested_configuration,title:t.createElement("span",null,"Launch new ",t.createElement("em",null,c)," input"),submitButtonText:"Launch Input",helpBlock:"Select a name of your new input that describes it.",typeName:s,submitAction:this._createInput})}return t.createElement(A,{className:"content"},t.createElement(l.Col,{md:12},t.createElement(L,{className:"form-inline",onSubmit:this._openModal},t.createElement("div",{className:"form-group",style:{width:300}},t.createElement(a.l6,{placeholder:"Select input",options:this._formatSelectOptions(),matchProp:"label",onChange:this._onInputSelect,value:s})),"\xA0",t.createElement(l.Button,{bsStyle:"success",type:"submit",disabled:!s},"Launch new input"),t.createElement(a.yr,{href:"https://marketplace.graylog.org/",bsStyle:"info",onClick:()=>{this.props.sendTelemetry(b.g.INPUTS.FIND_MORE_CLICKED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"inputs-find-more"})},style:{marginLeft:10}},"Find more inputs")),e||r))}}),V=(0,C.A)((0,x.A)($));var U=i("Lpa6AnJn"),Z=i("kqAR+wt5"),z=i.n(Z),w=i("+qc3iAHh"),K=i("8wYeYPUw"),B=i("RCNj0OY4"),It=Object.defineProperty,St=(e,n,s)=>n in e?It(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,O=(e,n,s)=>(St(e,typeof n!="symbol"?n+"":n,s),s);class Q extends t.Component{constructor(n){super(n),O(this,"_handleChange",(s,o)=>{const r={};r[s]=o,this.setState(r)}),O(this,"_onSubmit",s=>{const o=z().extend(s,{global:B.A.isCloud()||this.state.global,node:this.state.node});this.props.submitAction(o)}),O(this,"open",()=>{this.configurationForm.current&&this.configurationForm.current.open()}),O(this,"getValues",()=>{const{values:s}=this.props;return s||(this.configurationForm.current?this.configurationForm.current.getValue().configuration:{})}),O(this,"getTitleValue",()=>{const{titleValue:s}=this.props;return s||(this.configurationForm.current?this.configurationForm.current.getValue().titleValue:"")}),this.configurationForm=t.createRef(),this.state={global:this.props.globalValue!==void 0?this.props.globalValue:!1,node:this.props.nodeValue!==void 0?this.props.nodeValue:void 0}}render(){const n=this.getValues(),s=this.getTitleValue();return t.createElement(w.lD,{...this.props,ref:this.configurationForm,values:n,titleValue:s,submitAction:this._onSubmit},t.createElement(K.A,null,t.createElement(gt,{onChange:this._handleChange,global:this.state.global,node:this.state.node})))}}O(Q,"propTypes",{globalValue:p().bool,nodeValue:p().string,titleValue:p().string,submitAction:p().func.isRequired,values:p().object,submitButtonText:p().string.isRequired}),O(Q,"defaultProps",{globalValue:void 0,nodeValue:void 0,titleValue:void 0,values:void 0});const X=Q;var q=i("ty2gyrHp"),_t=i("yGRmSjYM"),W=i("d4kzUuQm"),vt=i("xMMaR1wr");const Tt=_()({displayName:"InputListItem",propTypes:{input:p().object.isRequired,currentNode:p().object.isRequired,permissions:p().array.isRequired,sendTelemetry:p().func.isRequired,location:p().object.isRequired},mixins:[_t.Ay,I().connect(v.P)],_deleteInput(){this.props.sendTelemetry(b.g.INPUTS.INPUT_DELETED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"input-delete"}),window.confirm(`Do you really want to delete input '${this.props.input.title}'?`)&&y.j.delete(this.props.input)},_openStaticFieldForm(){this.staticFieldForm.open()},_editInput(){const{sendTelemetry:e,location:n}=this.props;this.configurationForm.open(),e(b.g.INPUTS.INPUT_EDIT_CLICKED,{app_pathname:(0,S.i)(n.pathname),app_action_value:"show-received-messages"})},_updateInput(e){y.j.update(this.props.input.id,e),this.props.sendTelemetry(b.g.INPUTS.INPUT_UPDATED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"input-edit"})},render(){var e,n;if(!this.state.inputTypes)return t.createElement(a.y$,null);const{input:s,sendTelemetry:o,location:r}=this.props,c=this.state.inputDescriptions[s.type],d=t.createElement("span",null,this.props.input.name,"\xA0 (",this.props.input.id,") \xA0",t.createElement(ct,{input:this.props.input})),h=[],g=s.type==="org.graylog.plugins.forwarder.input.ForwarderServiceInput"?"gl2_forwarder_input":"gl2_source_input";if(this.isPermitted(this.props.permissions,["searches:relative"])&&h.push(t.createElement(q.m,{key:`received-messages-${this.props.input.id}`,to:W.Ay.search(`${g}:${this.props.input.id}`,(0,vt.A)())},t.createElement(l.Button,{onClick:()=>{o(b.g.INPUTS.SHOW_RECEIVED_MESSAGES_CLICKED,{app_pathname:(0,S.i)(r.pathname),app_action_value:"show-received-messages"})}},"Show received messages"))),this.isPermitted(this.props.permissions,[`inputs:edit:${this.props.input.id}`])){if(!B.A.isCloud()){let D;this.props.input.global?D=W.Ay.global_input_extractors(this.props.input.id):D=W.Ay.local_input_extractors((n=(e=this.props.currentNode)==null?void 0:e.node)==null?void 0:n.node_id,this.props.input.id),h.push(t.createElement(q.m,{key:`manage-extractors-${this.props.input.id}`,to:D},t.createElement(l.Button,{onClick:()=>{o(b.g.INPUTS.MANAGE_EXTRACTORS_CLICKED,{app_pathname:(0,S.i)(r.pathname),app_action_value:"manage-extractors"})}},"Manage extractors")))}h.push(t.createElement(ut,{key:`input-state-control-${this.props.input.id}`,input:this.props.input}))}let P;this.props.input.global||(P=t.createElement(q.m,{to:W.Ay.filtered_metrics(this.props.input.node,this.props.input.id)},t.createElement(l.MenuItem,{key:`show-metrics-${this.props.input.id}`,onClick:()=>{o(b.g.INPUTS.SHOW_METRICS_CLICKED,{app_pathname:(0,S.i)(r.pathname),app_action_value:"show-metrics"})}},"Show metrics"))),h.push(t.createElement(l.DropdownButton,{key:`more-actions-${this.props.input.id}`,title:"More actions",id:`more-actions-dropdown-${this.props.input.id}`,pullRight:!0},t.createElement(a.Wj,{permissions:`inputs:edit:${this.props.input.id}`},t.createElement(l.MenuItem,{key:`edit-input-${this.props.input.id}`,onSelect:this._editInput,disabled:c===void 0},"Edit input")),P,t.createElement(a.Wj,{permissions:`inputs:edit:${this.props.input.id}`},t.createElement(l.MenuItem,{key:`add-static-field-${this.props.input.id}`,onSelect:this._openStaticFieldForm},"Add static field")),t.createElement(a.Wj,{permissions:"inputs:terminate"},t.createElement(l.MenuItem,{key:`divider-${this.props.input.id}`,divider:!0})),t.createElement(a.Wj,{permissions:"inputs:terminate"},t.createElement(l.MenuItem,{key:`delete-input-${this.props.input.id}`,onSelect:this._deleteInput},"Delete input"))));let f;!this.props.input.global&&this.props.input.node&&(f=t.createElement("span",null,"On node"," ",t.createElement(a.Gk,{nodeId:this.props.input.node})));const m=c?t.createElement(X,{ref:D=>{this.configurationForm=D},key:`edit-form-input-${s.id}`,globalValue:s.global,nodeValue:s.node,configFields:c.requested_configuration,title:`Editing Input ${s.title}`,titleValue:s.title,typeName:s.type,includeTitleField:!0,submitAction:this._updateInput,submitButtonText:"Update input",values:s.attributes}):null,E=t.createElement("div",null,t.createElement(l.Col,{md:8},t.createElement(w.Xz,{className:"configuration-well",id:s.id,configuration:s.attributes,typeDefinition:c||{}}),t.createElement(yt,{ref:D=>{this.staticFieldForm=D},input:this.props.input}),t.createElement(ft,{input:this.props.input})),t.createElement(l.Col,{md:4},t.createElement(dt,{input:s})),m);return t.createElement(a.z5,{key:`entry-list-${this.props.input.id}`,title:this.props.input.title,titleSuffix:d,description:f,createdFromContentPack:!!this.props.input.content_pack,actions:h,contentRow:E})}}),st=(0,C.A)((0,x.A)(Tt));var it=i("1/PeS1Oa"),ot=i("gn61rwrR"),Nt=i("eFxcQyPT"),at=i("IA3Ku5lS");const tt=(0,at.rN)("core.SingleNode",()=>I().createActions({get:{asyncResult:!0}})),bt=(0,at.Bv)("core.SingleNode",()=>I().createStore({listenables:[tt],sourceUrl:"/system/cluster/node",node:void 0,init(){this._propagateState()},getInitialState(){return this._getNodeInfo()},_getNodeInfo(){return{node:this.node}},_propagateState(){this.trigger(this._getNodeInfo())},get(e){const n=(0,Nt.Ay)("GET",S.H3(e?S.Tp(this.sourceUrl,e):this.sourceUrl)).then(s=>{this.node=s,this._propagateState()});tt.get.promise(n)}}));var G=i("8fnsnG21");const Ct=(0,R.default)(l.Row)`
h2 {
margin-bottom: 5px;
}
.alert {
margin-top: 10px;
}
.static-fields {
margin-top: 10px;
margin-left: 3px;
ul {
margin: 0;
padding: 0;
.remove-static-field {
margin-left: 5px;
}
}
}
`,At=(e,n)=>{const{inputs:s}=e!=null?e:{},o=s==null?void 0:s.filter(c=>c.global===!0).sort((c,d)=>(0,it.m)(c.title,d.title));let r=s==null?void 0:s.filter(c=>c.global===!1).sort((c,d)=>(0,it.m)(c.title,d.title));return n!=null&&n.node_id&&(r=r==null?void 0:r.filter(c=>c.node===n.node_id)),{globalInputs:o,localInputs:r}},Pt=(e,n,s)=>{const o=RegExp(s,"i"),r=c=>o.test(c.title);return!e||!n||!s||s.length<=0?{filteredGlobalInputs:e,filteredLocalInputs:n}:{filteredGlobalInputs:e.filter(r),filteredLocalInputs:n.filter(r)}},Dt=({permissions:e,node:n})=>{(0,t.useEffect)(()=>{v.L.list(),y.j.list(),tt.get()},[]);const s=(0,G.P)(bt),{globalInputs:o,localInputs:r}=(0,G.P)(y.C,m=>At(m,n)),[c,d]=(0,t.useState)(),h=(0,t.useCallback)(()=>d(void 0),[]),{filteredGlobalInputs:g,filteredLocalInputs:P}=(0,t.useMemo)(()=>Pt(o,r,c),[c,o,r]),f=n?" on this node":"";return r&&o&&s&&P&&g?t.createElement("div",null,!n&&t.createElement(a.Wj,{permissions:"inputs:create"},t.createElement(V,null)),t.createElement(Ct,{id:"filter-input",className:"content"},t.createElement(l.Col,{md:12},t.createElement(a.B9,{onSearch:d,topMargin:0,onReset:h,placeholder:"Filter by title"}),t.createElement("br",null),t.createElement("h2",null,"Global inputs \xA0",t.createElement("small",null,o.length," configured",f)),t.createElement(ot.A,{bsNoItemsStyle:"info",noItemsText:o.length<=0?"There are no global inputs.":"No global inputs match the filter",items:g.map(m=>t.createElement(st,{key:m.id,input:m,currentNode:s,permissions:e}))}),t.createElement("br",null),t.createElement("br",null),t.createElement("h2",null,"Local inputs \xA0",t.createElement("small",null,r.length," configured",f)),t.createElement(ot.A,{bsNoItemsStyle:"info",noItemsText:r.length<=0?"There are no local inputs.":"No local inputs match the filter",items:P.map(m=>t.createElement(st,{key:m.id,input:m,currentNode:s,permissions:e}))})))):t.createElement(a.y$,null)};class Rt{constructor(){this.mapping={CREATED:0,INITIALIZED:1,INVALID_CONFIGURATION:2,STARTING:3,RUNNING:4,FAILED:2,STOPPING:1,STOPPED:0,TERMINATED:0}}compare(n,s){return this.mapping[n.toUpperCase()]-this.mapping[s.toUpperCase()]}}const Mt=Rt;var H=i("h0mKhxLv"),rt=i("Vg8s2y9S");const lt=new Mt,pt=({input:e})=>{const{inputStates:n}=(0,G.P)(H.G),{nodes:s}=(0,G.P)(rt.j),o=f=>{const m=f.reduce((D,jt)=>D+jt.count,0);if(e.global&&m!==Object.keys(s).length)return"warning";const{state:E}=f[0];switch(E){case"RUNNING":return"success";case"FAILED":case"STOPPED":return"danger";case"STARTING":return"info";default:return"warning"}},r=f=>e.global?f.map(m=>`${m.count} ${m.state}`).join(", "):f[0].state;if(!(n&&s))return t.createElement(a.y$,null);const d=e.id,h={};n[d]&&Object.keys(n[d]).forEach(f=>{const{state:m}=n[d][f];h[m]||(h[m]=[]),h[m].push(f)});const g=Object.keys(h).sort(lt.compare.bind(lt)).map(f=>({state:f,count:h[f].length}));if(g.length>0){const f=g.map(m=>h[m.state].map(E=>t.createElement("small",null,t.createElement(a.Gk,{nodeId:E}),": ",m.state,t.createElement("br",null))));return t.createElement(a.N,{trigger:"click",placement:"bottom",overlay:f,rootClose:!0,title:`Input States for ${e.title}`},t.createElement(l.Label,{bsStyle:o(g),title:"Click to show details",bsSize:"xsmall",style:{cursor:"pointer"}},r(g)))}const P=e.global||e.node===void 0?"0 RUNNING":"NOT RUNNING";return t.createElement(l.Label,{bsStyle:"warning",bsSize:"xsmall"},P)};pt.propTypes={input:p().object.isRequired};const ct=pt;function Ft(e){return e.inputStates?e.inputStates[this.props.input.id]:void 0}const xt=_()({displayName:"InputStateControl",propTypes:{input:p().object.isRequired,sendTelemetry:p().func.isRequired,location:p().object.isRequired},mixins:[I().connectFilter(H.G,"inputState",Ft)],getInitialState(){return{loading:!1}},_isInputRunning(){if(!this.state.inputState)return!1;const e=Object.keys(this.state.inputState);return e.length===0?!1:e.some(n=>{const s=this.state.inputState[n];return s.state==="RUNNING"||s.state==="STARTING"||s.state==="FAILING"})},_startInput(){this.setState({loading:!0}),this.props.sendTelemetry(b.g.INPUTS.INPUT_START_CLICKED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"start-input"}),H.G.start(this.props.input).finally(()=>{this.setState({loading:!1})})},_stopInput(){this.setState({loading:!0}),this.props.sendTelemetry(b.g.INPUTS.INPUT_STOP_CLICKED,{app_pathname:(0,S.i)(this.props.location.pathname),app_action_value:"stop-input"}),H.G.stop(this.props.input).finally(()=>{this.setState({loading:!1})})},render(){return this._isInputRunning()?t.createElement(l.Button,{bsStyle:"primary",onClick:this._stopInput,disabled:this.state.loading},this.state.loading?"Stopping...":"Stop input"):t.createElement(l.Button,{bsStyle:"success",onClick:this._startInput,disabled:this.state.loading},this.state.loading?"Starting...":"Start input")}}),ut=(0,C.A)((0,x.A)(xt));var Ot=i("9pdI12pI"),Lt=i.n(Ot),k=i("zkmy/ViL"),et=i("woUyHGxd");const Ut=R.default.span(({theme:e})=>(0,R.css)`
.total {
color: ${e.colors.gray[70]};
}
.value {
font-family: ${e.fonts.family.monospace};
}
.persec {
margin-left: 3px;
}
.channel-direction {
position: relative;
left: -1px;
}
.channel-direction-down {
position: relative;
top: 1px;
}
.channel-direction-up {
position: relative;
top: -1px;
}
`),dt=_()({displayName:"InputThroughput",propTypes:{input:p().object.isRequired},mixins:[I().connect(et.$)],getInitialState(){return{showDetails:!1}},UNSAFE_componentWillMount(){this._metricNames().forEach(e=>et.p.addGlobal(e))},componentWillUnmount(){this._metricNames().forEach(e=>et.p.removeGlobal(e))},_metricNames(){return[this._prefix("incomingMessages"),this._prefix("emptyMessages"),this._prefix("open_connections"),this._prefix("total_connections"),this._prefix("written_bytes_1sec"),this._prefix("written_bytes_total"),this._prefix("read_bytes_1sec"),this._prefix("read_bytes_total")]},_prefix(e){const{input:n}=this.props;return`${n.type}.${n.id}.${e}`},_getValueFromMetric(e){if(e!=null)switch(e.type){case"meter":return e.metric.rate.mean;case"gauge":return e.metric.value;case"counter":return e.metric.count;default:return}},_calculateMetrics(e){const n={};return this._metricNames().forEach(s=>{n[s]=Object.keys(e).reduce((o,r)=>{if(!e[r][s])return o;const c=this._getValueFromMetric(e[r][s]);return c!==void 0?isNaN(o)?c:o+c:o},NaN)}),n},_formatCount(e){return Lt()(e).format("0,0")},_formatNetworkStats(e,n,s,o){return t.createElement(Ut,null,t.createElement("span",null,"Network IO: "),t.createElement("span",{className:"persec"},t.createElement(a.In,{name:"arrow_drop_down",className:"channel-direction channel-direction-down"}),t.createElement("span",{className:"rx value"},k.A.formatBytes(s)," "),t.createElement(a.In,{name:"arrow_drop_up",className:"channel-direction channel-direction-up"}),t.createElement("span",{className:"tx value"},k.A.formatBytes(e))),t.createElement("span",{className:"total"},t.createElement("span",null," (total: "),t.createElement(a.In,{name:"arrow_drop_down",className:"channel-direction channel-direction-down"}),t.createElement("span",{className:"rx value"},k.A.formatBytes(o)," "),t.createElement(a.In,{name:"arrow_drop_up",className:"channel-direction channel-direction-up"}),t.createElement("span",{className:"tx value"},k.A.formatBytes(n)),t.createElement("span",null," )")),t.createElement("br",null))},_formatConnections(e,n){return t.createElement("span",null,"Active connections: ",t.createElement("span",{className:"active"},this._formatCount(e)," "),"(",t.createElement("span",{className:"total"},this._formatCount(n))," total)",t.createElement("br",null))},_formatAllNodeDetails(e){return t.createElement("span",null,t.createElement("hr",{key:"separator"}),Object.keys(e).map(n=>this._formatNodeDetails(n,e[n])))},_formatNodeDetails(e,n){const{input:s}=this.props,o=this._getValueFromMetric(n[this._prefix("open_connections")]),r=this._getValueFromMetric(n[this._prefix("total_connections")]),c=this._getValueFromMetric(n[this._prefix("emptyMessages")]),d=this._getValueFromMetric(n[this._prefix("written_bytes_1sec")]),h=this._getValueFromMetric(n[this._prefix("written_bytes_total")]),g=this._getValueFromMetric(n[this._prefix("read_bytes_1sec")]),P=this._getValueFromMetric(n[this._prefix("read_bytes_total")]);return t.createElement("span",{key:s.id+e},t.createElement(a.Gk,{nodeId:e}),t.createElement("br",null),!isNaN(d)&&this._formatNetworkStats(d,h,g,P),!isNaN(o)&&this._formatConnections(o,r),!isNaN(c)&&t.createElement("span",null,"Empty messages discarded: ",this._formatCount(c),t.createElement("br",null)),isNaN(d)&&isNaN(o)&&t.createElement("span",null,"No metrics available for this node"),t.createElement("br",null))},_toggleShowDetails(e){e.preventDefault();const{showDetails:n}=this.state;this.setState({showDetails:!n})},render(){const{metrics:e,showDetails:n}=this.state,{input:s}=this.props;if(!e)return t.createElement(a.y$,null);const o=this._calculateMetrics(e),r=o[this._prefix("incomingMessages")],c=o[this._prefix("emptyMessages")],d=o[this._prefix("open_connections")],h=o[this._prefix("total_connections")],g=o[this._prefix("written_bytes_1sec")],P=o[this._prefix("written_bytes_total")],f=o[this._prefix("read_bytes_1sec")],m=o[this._prefix("read_bytes_total")];return t.createElement("div",{className:"graylog-input-metrics"},t.createElement("h3",null,"Throughput / Metrics"),t.createElement("span",null,isNaN(r)&&isNaN(g)&&isNaN(d)&&t.createElement("i",null,"No metrics available for this input"),!isNaN(r)&&t.createElement("span",null,"1 minute average rate: ",this._formatCount(r)," msg/s",t.createElement("br",null)),!isNaN(g)&&this._formatNetworkStats(g,P,f,m),!isNaN(d)&&this._formatConnections(d,h),!isNaN(c)&&t.createElement("span",null,"Empty messages discarded: ",this._formatCount(c),t.createElement("br",null)),!isNaN(g)&&s.global&&t.createElement("a",{href:"",onClick:this._toggleShowDetails},n?"Hide":"Show"," details"),!isNaN(g)&&n&&this._formatAllNodeDetails(e)))}});var mt=i("0j5jZleo"),Bt=Object.defineProperty,$t=(e,n,s)=>n in e?Bt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,Y=(e,n,s)=>($t(e,typeof n!="symbol"?n+"":n,s),s);class ht extends t.Component{constructor(){super(...arguments),Y(this,"_deleteStaticField",n=>()=>{window.confirm(`Are you sure you want to remove static field '${n}' from '${this.props.input.title}'?`)&&mt.B.destroy(this.props.input,n)}),Y(this,"_deleteButton",n=>t.createElement(l.Button,{bsStyle:"link",bsSize:"xsmall",style:{verticalAlign:"baseline"},onClick:this._deleteStaticField(n)},t.createElement(a.In,{name:"remove"}))),Y(this,"_formatStaticFields",n=>{const s=[];return Object.keys(n).forEach(r=>{s.push(t.createElement("li",{key:`${r}-field`},t.createElement("strong",null,r,":")," ",n[r]," ",this._deleteButton(r)))}),s})}render(){return Object.keys(this.props.input.static_fields).length===0?t.createElement("div",null):t.createElement("div",{className:"static-fields"},t.createElement("h3",{style:{marginBottom:5}},"Static fields"),t.createElement("ul",null,this._formatStaticFields(this.props.input.static_fields)))}}Y(ht,"propTypes",{input:p().object.isRequired});const ft=ht,nt=({global:e=!1,node:n,onChange:s})=>{const{nodes:o}=(0,G.P)(rt.j),[r,c]=(0,t.useState)(e),[d,h]=(0,t.useState)(n);(0,t.useEffect)(()=>{if(!n&&o){const E=Object.keys(o);E.length===1&&(s("node",E[0]),h(E[0]))}},[o]);const g=(0,t.useCallback)(E=>{const D=E.target.checked;c(D),D?(h("placeholder"),s("node",void 0)):s("node",d),s("global",D)},[s,d,h,c]),P=(0,t.useCallback)(E=>{h(E.target.value),s("node",E.target.value)},[h,s]);if(!o)return t.createElement(a.y$,null);const f=Object.keys(o).map(E=>t.createElement("option",{key:E,value:E},o[E].short_node_id," / ",o[E].hostname)),m=r?null:t.createElement(l.Input,{id:"node-select",type:"select",label:"Node",placeholder:"placeholder",value:n,help:"On which node should this input start",onChange:P,required:!0},t.createElement("option",{key:"placeholder",value:""},"Select Node"),f);return t.createElement("span",null,t.createElement(l.Input,{id:"global-checkbox",type:"checkbox",label:"Global",help:"Should this input start on all nodes",checked:r,onChange:g}),m)};nt.propTypes={global:p().bool,onChange:p().func.isRequired,node:p().string},nt.defaultProps={global:!1,node:void 0};const gt=nt;var wt=Object.defineProperty,Gt=(e,n,s)=>n in e?wt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,J=(e,n,s)=>(Gt(e,typeof n!="symbol"?n+"":n,s),s);class Et extends t.Component{constructor(n){super(n),J(this,"open",()=>{this.setState({showModal:!0})}),J(this,"close",()=>{this.setState({showModal:!1})}),J(this,"_addStaticField",()=>{const s=this.fieldName.getValue(),o=this.fieldValue.getValue();mt.B.create(this.props.input,s,o).then(()=>this.close())}),this.state={showModal:!1}}render(){return t.createElement(l.BootstrapModalForm,{show:this.state.showModal,title:"Add static field",submitButtonText:"Add field",onCancel:this.close,onSubmitForm:this._addStaticField},t.createElement("p",null,"Define a static field that is added to every message that comes in via this input. The field is not overwritten If the message already has that key. Key must only contain alphanumeric characters or underscores and not be a reserved field."),t.createElement(l.Input,{ref:n=>{this.fieldName=n},type:"text",id:"field-name",label:"Field name",required:!0,pattern:"[A-Za-z0-9_]*",title:"Should consist only of alphanumeric characters and underscores.",autoFocus:!0}),t.createElement(l.Input,{ref:n=>{this.fieldValue=n},type:"text",id:"field-value",label:"Field value",required:!0}))}}J(Et,"propTypes",{input:p().object.isRequired});const yt=Et},h0mKhxLv:(j,M,i)=>{i.d(M,{G:()=>R});var t=i("JnTtTRmZ"),T=i.n(t),p=i("jAGDuYSC"),N=i("MdYBRjRJ"),_=i("U1Iufsob"),F=i("eFxcQyPT"),I=i("IA3Ku5lS");const R=(0,I.Bv)("core.InputStates",()=>T().createStore({listenables:[],init(){this.list()},getInitialState(){return{inputStates:this.inputStates}},list(){const u=N.H3(_.A.ClusterInputStatesController.list().url);return(0,F.Ay)("GET",u).then(l=>{const a={};return Object.keys(l).forEach(y=>{l[y]&&l[y].forEach(v=>{a[v.id]||(a[v.id]={}),a[v.id][y]=v})}),this.inputStates=a,this.trigger({inputStates:this.inputStates}),a})},_checkInputStateChangeResponse(u,l,a){const y=Object.keys(l).filter(x=>u.global?!0:x===u.node),v=y.filter(x=>l[x]===null);v.length===0?p.A.success(`Request to ${a.toLowerCase()} input '${u.title}' was sent successfully.`,`Input '${u.title}' will be ${a==="START"?"started":"stopped"} shortly`):v.length===y.length?p.A.error(`Request to ${a.toLowerCase()} input '${u.title}' failed. Check your Graylog logs for more information.`,`Input '${u.title}' could not be ${a==="START"?"started":"stopped"}`):p.A.warning(`Request to ${a.toLowerCase()} input '${u.title}' failed in some nodes. Check your Graylog logs for more information.`,`Input '${u.title}' could not be ${a==="START"?"started":"stopped"} in all nodes`)},start(u){const l=N.H3(_.A.ClusterInputStatesController.start(u.id).url);return(0,F.Ay)("PUT",l).then(a=>(this._checkInputStateChangeResponse(u,a,"START"),this.list(),a),a=>{p.A.error(`Error starting input '${u.title}': ${a}`,`Input '${u.title}' could not be started`)})},stop(u){const l=N.H3(_.A.ClusterInputStatesController.stop(u.id).url);return(0,F.Ay)("DELETE",l).then(a=>(this._checkInputStateChangeResponse(u,a,"STOP"),this.list(),a),a=>{p.A.error(`Error stopping input '${u.title}': ${a}`,`Input '${u.title}' could not be stopped`)})}}))},wToqYuKZ:(j,M,i)=>{i.d(M,{L:()=>I,P:()=>R});var t=i("JnTtTRmZ"),T=i.n(t),p=i("MdYBRjRJ"),N=i("eFxcQyPT"),_=i("jAGDuYSC"),F=i("IA3Ku5lS");const I=(0,F.rN)("core.InputTypes",()=>T().createActions({list:{asyncResult:!0},get:{asyncResult:!0}})),R=(0,F.Bv)("core.InputTypes",()=>T().createStore({listenables:[I],sourceUrl:"/system/inputs/types",inputTypes:void 0,inputDescriptions:void 0,init(){this.list()},getInitialState(){return{inputTypes:this.inputTypes,inputDescriptions:this.inputDescriptions}},list(){const u=(0,N.Ay)("GET",(0,p.H3)(this.sourceUrl)),l=(0,N.Ay)("GET",(0,p.H3)(`${this.sourceUrl}/all`)),a=Promise.all([u,l]);a.then(([y,v])=>{this.inputTypes=y.types,this.inputDescriptions=v,this.trigger(this.getInitialState())},y=>{_.A.error(`Fetching Input Types failed with status: ${y}`,"Could not retrieve Inputs")}),I.list.promise(a)},get(u){const l=(0,N.Ay)("GET",(0,p.H3)(`${this.sourceUrl}/${u}`));l.catch(a=>{_.A.error(`Fetching input ${u} failed with status: ${a}`,"Could not retrieve input")}),I.get.promise(l)}}))},xMMaR1wr:(j,M,i)=>{i.d(M,{A:()=>T});const T=()=>{const p=Date.now(),N=new Date(p-26*60*6e4).toISOString(),_=new Date(p+26*60*6e4).toISOString();return{rangetype:"absolute",from:N,to:_}}}}]);})();
//# sourceMappingURL=bb8c8232-9099.9b2b292086f3eed4211a.js.map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy