All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web-interface.assets.1255d548-5299.82092a4c17aee48064a9.js Maven / Gradle / Ivy

There is a newer version: 6.1.4
Show newest version
"use strict";(()=>{(self.webpackChunkgraylog_web_interface=self.webpackChunkgraylog_web_interface||[]).push([["1255d548-5299"],{Lpa6AnJn:(w,R,i)=>{i.d(R,{Z:()=>b});var t=i("Z7aTuO5B"),I=i("ii0bleBb"),p=i.n(I),v=i("J6y4/h8P"),h=i("VPaD/Np4"),_=i.n(h),m=i("uZqmR+ju"),T=i("dsvqAVKU");const c=v.default.div`
  display: flex;
  flex-wrap: wrap;

  .form-group {
    margin: 0 15px 0 0;
  }
`,r=(0,v.default)(m.Input)`
  min-width: 400px;
`,a="placeholder",f=({id:C,title:N,type:F})=>t.createElement("option",{key:C,value:C},N," (",F,")"),S=(C,N)=>C.title.localeCompare(N.title),x=({input:{type:C,title:N}})=>t.createElement(r,{id:`${C}-select`,type:"select",disabled:!0},t.createElement("option",null,`${N} (${C})`)),g=({disabled:C,inputs:N,onLoadMessage:F,preselectedInputId:L,title:Q})=>{const[M,k]=(0,t.useState)(L||a),Z=(0,t.useCallback)(B=>k(B.target.value),[]),K=(0,t.useCallback)(()=>F(M),[F,M]),U=(0,t.useMemo)(()=>N==null?void 0:N.get(L),[N,L]);if(U)return t.createElement(c,null,t.createElement(x,{input:U}),t.createElement(m.Button,{bsStyle:"info",disabled:M===a,onClick:K},Q));if(N){const B=N.sort(S).map(f);return t.createElement(c,null,t.createElement(r,{id:"placeholder-select",type:"select","aria-label":"server input select",value:M,onChange:Z,placeholder:a},t.createElement("option",{value:a},"Select an Input"),B.toArray()),t.createElement(m.Button,{bsStyle:"info",disabled:C||M===a,onClick:K},Q))}return t.createElement(T.Z,null)};g.propTypes={inputs:I.object,title:I.string.isRequired,preselectedInputId:I.string,onLoadMessage:I.func,disabled:I.bool},g.defaultProps={inputs:h.Map(),onLoadMessage:()=>{},preselectedInputId:void 0,disabled:!1};const b=g},oQQQ2VXa:(w,R,i)=>{i.d(R,{M5:()=>Y,s_:()=>rt,Et:()=>lt,$B:()=>dt,JQ:()=>pt,t5:()=>_t,vk:()=>mt,yV:()=>ft});var t=i("Z7aTuO5B"),I=i("ii0bleBb"),p=i.n(I),v=i("D4SbLiE/"),h=i.n(v),_=i("JnTtTRmZ"),m=i.n(_),T=i("J6y4/h8P"),c=i("QL8i6bcz"),r=i("uZqmR+ju"),a=i("/GOzvPf6"),f=i("yEuO7gC5"),S=i("wToqYuKZ"),x=i("BqxuktKK"),g=i("MdYBRjRJ"),b=i("v4GbOr/o"),C=i("HCsT5Gmk");const N=(0,T.default)(r.Row)`
  margin-bottom: 8px;
`,F=h()({displayName:"CreateInputControl",propTypes:{sendTelemetry:p().func.isRequired,location:p().object.isRequired},mixins:[m().connect(S.W)],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,l)=>o.label.toLowerCase().localeCompare(l.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.A.INPUTS.INPUT_SELECTED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"input-select",event_details:{value:e}}),S._.get.triggerPromise(e).then(n=>this.setState({selectedInputDefinition:n}))},_openModal(e){e.preventDefault();const{selectedInput:n}=this.state,s=c.G.exports("inputConfiguration").find(o=>o.type===n);if(s){const o=()=>this.setState({customInputsComponent:void 0}),l=s.component;this.setState({customInputsComponent:t.createElement(l,{onClose:o})})}this.configurationForm.open()},_createInput(e){this.props.sendTelemetry(b.A.INPUTS.INPUT_CREATED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"input-create"}),f.x.create(e).then(()=>{this.setState(this.getInitialState())})},render(){let e;const{selectedInputDefinition:n,selectedInput:s,inputTypes:o,customInputsComponent:l}=this.state;if(n&&!l){const u=o[s];e=t.createElement(Y,{ref:d=>{this.configurationForm=d},key:"configuration-form-input",configFields:n.requested_configuration,title:t.createElement("span",null,"Launch new ",t.createElement("em",null,u)," input"),submitButtonText:"Launch Input",helpBlock:"Select a name of your new input that describes it.",typeName:s,submitAction:this._createInput})}return t.createElement(N,{className:"content"},t.createElement(r.Col,{md:12},t.createElement("form",{className:"form-inline",onSubmit:this._openModal},t.createElement("div",{className:"form-group",style:{width:300}},t.createElement(a.Ph,{placeholder:"Select input",options:this._formatSelectOptions(),matchProp:"label",onChange:this._onInputSelect,value:s})),"\xA0",t.createElement(r.Button,{bsStyle:"success",type:"submit",disabled:!s},"Launch new input"),t.createElement(a.bd,{href:"https://marketplace.graylog.org/",bsStyle:"info",onClick:()=>{this.props.sendTelemetry(b.A.INPUTS.FIND_MORE_CLICKED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"inputs-find-more"})},style:{marginLeft:10}},"Find more inputs")),e||l))}}),L=(0,C.Z)((0,x.Z)(F));var Q=i("Lpa6AnJn"),M=i("kqAR+wt5"),k=i.n(M),Z=i("+qc3iAHh"),K=i("8wYeYPUw"),U=i("RCNj0OY4"),B=Object.defineProperty,Et=(e,n,s)=>n in e?B(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,O=(e,n,s)=>(Et(e,typeof n!="symbol"?n+"":n,s),s);class H extends t.Component{constructor(n){super(n),O(this,"_handleChange",(s,o)=>{const l={};l[s]=o,this.setState(l)}),O(this,"_onSubmit",s=>{const o=k().extend(s,{global:U.Z.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(Z.fI,{...this.props,ref:this.configurationForm,values:n,titleValue:s,submitAction:this._onSubmit},t.createElement(K.Z,null,t.createElement(mt,{onChange:this._handleChange,global:this.state.global,node:this.state.node})))}}O(H,"propTypes",{globalValue:p().bool,nodeValue:p().string,titleValue:p().string,submitAction:p().func.isRequired,values:p().object,submitButtonText:p().string.isRequired}),O(H,"defaultProps",{globalValue:void 0,nodeValue:void 0,titleValue:void 0,values:void 0});const Y=H;var z=i("ty2gyrHp"),gt=i("0TVxnHwi"),V=i("d4kzUuQm");const It=h()({displayName:"InputListItem",propTypes:{input:p().object.isRequired,currentNode:p().object.isRequired,permissions:p().array.isRequired,sendTelemetry:p().func.isRequired,location:p().object.isRequired},mixins:[gt.ZP,m().connect(S.W)],_deleteInput(){this.props.sendTelemetry(b.A.INPUTS.INPUT_DELETED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"input-delete"}),window.confirm(`Do you really want to delete input '${this.props.input.title}'?`)&&f.x.delete(this.props.input)},_openStaticFieldForm(){this.staticFieldForm.open()},_editInput(){const{sendTelemetry:e,location:n}=this.props;this.configurationForm.open(),e(b.A.INPUTS.INPUT_EDIT_CLICKED,{app_pathname:(0,g.av)(n.pathname),app_action_value:"show-received-messages"})},_updateInput(e){f.x.update(this.props.input.id,e),this.props.sendTelemetry(b.A.INPUTS.INPUT_UPDATED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"input-edit"})},render(){if(!this.state.inputTypes)return t.createElement(a.$j,null);const{input:e,sendTelemetry:n,location:s}=this.props,o=this.state.inputDescriptions[e.type],l=t.createElement("span",null,this.props.input.name,"\xA0 (",this.props.input.id,") \xA0",t.createElement(rt,{input:this.props.input})),u=[],d=e.type==="org.graylog.plugins.forwarder.input.ForwarderServiceInput"?"gl2_forwarder_input":"gl2_source_input";if(this.isPermitted(this.props.permissions,["searches:relative"])&&u.push(t.createElement(z.J,{key:`received-messages-${this.props.input.id}`,to:V.ZP.search(`${d}:${this.props.input.id}`,{relative:0})},t.createElement(r.Button,{onClick:()=>{n(b.A.INPUTS.SHOW_RECEIVED_MESSAGES_CLICKED,{app_pathname:(0,g.av)(s.pathname),app_action_value:"show-received-messages"})}},"Show received messages"))),this.isPermitted(this.props.permissions,[`inputs:edit:${this.props.input.id}`])){if(!U.Z.isCloud()){let D;this.props.input.global?D=V.ZP.global_input_extractors(this.props.input.id):D=V.ZP.local_input_extractors(this.props.currentNode.node_id,this.props.input.id),u.push(t.createElement(z.J,{key:`manage-extractors-${this.props.input.id}`,to:D},t.createElement(r.Button,{onClick:()=>{n(b.A.INPUTS.MANAGE_EXTRACTORS_CLICKED,{app_pathname:(0,g.av)(s.pathname),app_action_value:"manage-extractors"})}},"Manage extractors")))}u.push(t.createElement(lt,{key:`input-state-control-${this.props.input.id}`,input:this.props.input}))}let E;this.props.input.global||(E=t.createElement(z.J,{to:V.ZP.filtered_metrics(this.props.input.node,this.props.input.id)},t.createElement(r.MenuItem,{key:`show-metrics-${this.props.input.id}`,onClick:()=>{n(b.A.INPUTS.SHOW_METRICS_CLICKED,{app_pathname:(0,g.av)(s.pathname),app_action_value:"show-metrics"})}},"Show metrics"))),u.push(t.createElement(r.DropdownButton,{key:`more-actions-${this.props.input.id}`,title:"More actions",id:`more-actions-dropdown-${this.props.input.id}`,pullRight:!0},t.createElement(a.AE,{permissions:`inputs:edit:${this.props.input.id}`},t.createElement(r.MenuItem,{key:`edit-input-${this.props.input.id}`,onSelect:this._editInput,disabled:o===void 0},"Edit input")),E,t.createElement(a.AE,{permissions:`inputs:edit:${this.props.input.id}`},t.createElement(r.MenuItem,{key:`add-static-field-${this.props.input.id}`,onSelect:this._openStaticFieldForm},"Add static field")),t.createElement(a.AE,{permissions:"inputs:terminate"},t.createElement(r.MenuItem,{key:`divider-${this.props.input.id}`,divider:!0})),t.createElement(a.AE,{permissions:"inputs:terminate"},t.createElement(r.MenuItem,{key:`delete-input-${this.props.input.id}`,onSelect:this._deleteInput},"Delete input"))));let y;!this.props.input.global&&this.props.input.node&&(y=t.createElement("span",null,"On node"," ",t.createElement(a.Zv,{nodeId:this.props.input.node})));const A=o?t.createElement(Y,{ref:D=>{this.configurationForm=D},key:`edit-form-input-${e.id}`,globalValue:e.global,nodeValue:e.node,configFields:o.requested_configuration,title:`Editing Input ${e.title}`,titleValue:e.title,typeName:e.type,includeTitleField:!0,submitAction:this._updateInput,submitButtonText:"Update input",values:e.attributes}):null,$=t.createElement("div",null,t.createElement(r.Col,{md:8},t.createElement(Z.$O,{className:"configuration-well",id:e.id,configuration:e.attributes,typeDefinition:o||{}}),t.createElement(ft,{ref:D=>{this.staticFieldForm=D},input:this.props.input}),t.createElement(dt,{input:this.props.input})),t.createElement(r.Col,{md:4},t.createElement(pt,{input:e})),A);return t.createElement(a.S6,{key:`entry-list-${this.props.input.id}`,title:this.props.input.title,titleSuffix:l,description:y,createdFromContentPack:!!this.props.input.content_pack,actions:u,contentRow:$})}}),nt=(0,C.Z)((0,x.Z)(It));var st=i("1/PeS1Oa"),it=i("gn61rwrR"),St=i("eFxcQyPT"),ot=i("IA3Ku5lS");const X=(0,ot.ei)("core.SingleNode",()=>m().createActions({get:{asyncResult:!0}})),yt=(0,ot.dS)("core.SingleNode",()=>m().createStore({listenables:[X],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,St.ZP)("GET",g.DC(e?g.em(this.sourceUrl,e):this.sourceUrl)).then(s=>{this.node=s,this._propagateState()});X.get.promise(n)}})),vt=(0,T.default)(r.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;
      }
    }
  }
`,_t=h()({displayName:"InputsList",propTypes:{permissions:p().array.isRequired,node:p().object},mixins:[m().connect(yt),m().listenTo(f.Q,"_splitInputs")],getDefaultProps(){return{node:void 0}},getInitialState(){return{globalInputs:void 0,localInputs:void 0,filteredGlobalInputs:void 0,filteredLocalInputs:void 0,filter:void 0}},componentDidMount(){S._.list(),f.x.list(),X.get()},_splitInputs(e){const{inputs:n}=e,s=n.filter(l=>l.global===!0).sort((l,u)=>(0,st.Q)(l.title,u.title));let o=n.filter(l=>l.global===!1).sort((l,u)=>(0,st.Q)(l.title,u.title));this.props.node&&(o=o.filter(l=>l.node===this.props.node.node_id)),this.setState({globalInputs:s,localInputs:o}),this._onFilterInputs(this.state.filter)},_isLoading(){return!(this.state.localInputs&&this.state.globalInputs&&this.state.node&&this.state.filteredLocalInputs&&this.state.filteredGlobalInputs)},_nodeAffix(){return this.props.node?" on this node":""},_onFilterInputs(e,n){const{globalInputs:s,localInputs:o}=this.state,l=RegExp(e,"i");if(!s||!o){n&&n();return}if(!e||e.length<=0){this.setState({filteredGlobalInputs:s,filteredLocalInputs:o,filter:void 0}),n&&n();return}const u=d=>l.test(d.title);this.setState(d=>({filteredGlobalInputs:d.globalInputs.filter(u),filteredLocalInputs:d.localInputs.filter(u),filter:e})),n&&n()},_onFilterReset(){this.setState(e=>({filteredGlobalInputs:e.globalInputs,filteredLocalInputs:e.localInputs,filter:void 0}))},render(){return this._isLoading()?t.createElement(a.$j,null):t.createElement("div",null,!this.props.node&&t.createElement(a.AE,{permissions:"inputs:create"},t.createElement(L,null)),t.createElement(vt,{id:"filter-input",className:"content"},t.createElement(r.Col,{md:12},t.createElement(a.UI,{onSearch:this._onFilterInputs,topMargin:0,onReset:this._onFilterReset,placeholder:"Filter by title"}),t.createElement("br",null),t.createElement("h2",null,"Global inputs \xA0",t.createElement("small",null,this.state.globalInputs.length," configured",this._nodeAffix())),t.createElement(it.Z,{bsNoItemsStyle:"info",noItemsText:this.state.globalInputs.length<=0?"There are no global inputs.":"No global inputs match the filter",items:this.state.filteredGlobalInputs.map(e=>t.createElement(nt,{key:e.id,input:e,currentNode:this.state.node,permissions:this.props.permissions}))}),t.createElement("br",null),t.createElement("br",null),t.createElement("h2",null,"Local inputs \xA0",t.createElement("small",null,this.state.localInputs.length," configured",this._nodeAffix())),t.createElement(it.Z,{bsNoItemsStyle:"info",noItemsText:this.state.localInputs.length<=0?"There are no local inputs.":"No local inputs match the filter",items:this.state.filteredLocalInputs.map(e=>t.createElement(nt,{key:e.id,input:e,currentNode:this.state.node,permissions:this.props.permissions}))}))))}});class Tt{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 bt=Tt;var G=i("h0mKhxLv"),at=i("Vg8s2y9S");const rt=h()({displayName:"InputStateBadge",propTypes:{input:p().object.isRequired},mixins:[m().connect(G.c),m().connect(at.S)],comparator:new bt,_labelClassForState(e){const{input:n}=this.props,{nodes:s}=this.state,o=e.reduce((u,d)=>u+d.count,0);if(n.global&&o!==Object.keys(s).length)return"warning";const{state:l}=e[0];switch(l){case"RUNNING":return"success";case"FAILED":case"STOPPED":return"danger";case"STARTING":return"info";default:return"warning"}},_textForState(e){const{input:n}=this.props;return n.global?e.map(s=>`${s.count} ${s.state}`).join(", "):e[0].state},_isLoading(){const{inputStates:e,nodes:n}=this.state;return!(e&&n)},render(){if(this._isLoading())return t.createElement(a.$j,null);const{input:e}=this.props,{inputStates:n}=this.state,s=e.id,o={};n[s]&&Object.keys(n[s]).forEach(d=>{const{state:E}=n[s][d];o[E]||(o[E]=[]),o[E].push(d)});const l=Object.keys(o).sort(this.comparator.compare.bind(this.comparator)).map(d=>({state:d,count:o[d].length}));if(l.length>0){const d=l.map(y=>o[y.state].map(A=>t.createElement("small",null,t.createElement(a.Zv,{nodeId:A}),": ",y.state,t.createElement("br",null)))),E=t.createElement(r.Popover,{id:"inputstate-badge-details",title:`Input States for ${e.title}`},d);return t.createElement(a.Ox,{trigger:"click",placement:"bottom",overlay:E,rootClose:!0},t.createElement(r.Label,{bsStyle:this._labelClassForState(l),title:"Click to show details",bsSize:"xsmall",style:{cursor:"pointer"}},this._textForState(l)))}const u=e.global||e.node===void 0?"0 RUNNING":"NOT RUNNING";return t.createElement(r.Label,{bsStyle:"warning",bsSize:"xsmall"},u)}});function Ct(e){return e.inputStates?e.inputStates[this.props.input.id]:void 0}const Nt=h()({displayName:"InputStateControl",propTypes:{input:p().object.isRequired,sendTelemetry:p().func.isRequired,location:p().object.isRequired},mixins:[m().connectFilter(G.c,"inputState",Ct)],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.A.INPUTS.INPUT_START_CLICKED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"start-input"}),G.c.start(this.props.input).finally(()=>{this.setState({loading:!1})})},_stopInput(){this.setState({loading:!0}),this.props.sendTelemetry(b.A.INPUTS.INPUT_STOP_CLICKED,{app_pathname:(0,g.av)(this.props.location.pathname),app_action_value:"stop-input"}),G.c.stop(this.props.input).finally(()=>{this.setState({loading:!1})})},render(){return this._isInputRunning()?t.createElement(r.Button,{bsStyle:"primary",onClick:this._stopInput,disabled:this.state.loading},this.state.loading?"Stopping...":"Stop input"):t.createElement(r.Button,{bsStyle:"success",onClick:this._startInput,disabled:this.state.loading},this.state.loading?"Starting...":"Start input")}}),lt=(0,C.Z)((0,x.Z)(Nt));var Pt=i("9pdI12pI"),Dt=i.n(Pt),j=i("zkmy/ViL"),q=i("woUyHGxd");const Rt=T.default.span(({theme:e})=>(0,T.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;
  }
`),pt=h()({displayName:"InputThroughput",propTypes:{input:p().object.isRequired},mixins:[m().connect(q.q)],getInitialState(){return{showDetails:!1}},UNSAFE_componentWillMount(){this._metricNames().forEach(e=>q.K.addGlobal(e))},componentWillUnmount(){this._metricNames().forEach(e=>q.K.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,l)=>{if(!e[l][s])return o;const u=this._getValueFromMetric(e[l][s]);return u!==void 0?isNaN(o)?u:o+u:o},NaN)}),n},_formatCount(e){return Dt()(e).format("0,0")},_formatNetworkStats(e,n,s,o){return t.createElement(Rt,null,t.createElement("span",null,"Network IO: "),t.createElement("span",{className:"persec"},t.createElement(a.JO,{name:"caret-down",className:"channel-direction channel-direction-down"}),t.createElement("span",{className:"rx value"},j.Z.formatBytes(s)," "),t.createElement(a.JO,{name:"caret-up",className:"channel-direction channel-direction-up"}),t.createElement("span",{className:"tx value"},j.Z.formatBytes(e))),t.createElement("span",{className:"total"},t.createElement("span",null," (total: "),t.createElement(a.JO,{name:"caret-down",className:"channel-direction channel-direction-down"}),t.createElement("span",{className:"rx value"},j.Z.formatBytes(o)," "),t.createElement(a.JO,{name:"caret-up",className:"channel-direction channel-direction-up"}),t.createElement("span",{className:"tx value"},j.Z.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")]),l=this._getValueFromMetric(n[this._prefix("total_connections")]),u=this._getValueFromMetric(n[this._prefix("emptyMessages")]),d=this._getValueFromMetric(n[this._prefix("written_bytes_1sec")]),E=this._getValueFromMetric(n[this._prefix("written_bytes_total")]),y=this._getValueFromMetric(n[this._prefix("read_bytes_1sec")]),A=this._getValueFromMetric(n[this._prefix("read_bytes_total")]);return t.createElement("span",{key:s.id+e},t.createElement(a.Zv,{nodeId:e}),t.createElement("br",null),!isNaN(d)&&this._formatNetworkStats(d,E,y,A),!isNaN(o)&&this._formatConnections(o,l),!isNaN(u)&&t.createElement("span",null,"Empty messages discarded: ",this._formatCount(u),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.$j,null);const o=this._calculateMetrics(e),l=o[this._prefix("incomingMessages")],u=o[this._prefix("emptyMessages")],d=o[this._prefix("open_connections")],E=o[this._prefix("total_connections")],y=o[this._prefix("written_bytes_1sec")],A=o[this._prefix("written_bytes_total")],$=o[this._prefix("read_bytes_1sec")],D=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(l)&&isNaN(y)&&isNaN(d)&&t.createElement("i",null,"No metrics available for this input"),!isNaN(l)&&t.createElement("span",null,"1 minute average rate: ",this._formatCount(l)," msg/s",t.createElement("br",null)),!isNaN(y)&&this._formatNetworkStats(y,A,$,D),!isNaN(d)&&this._formatConnections(d,E),!isNaN(u)&&t.createElement("span",null,"Empty messages discarded: ",this._formatCount(u),t.createElement("br",null)),!isNaN(y)&&s.global&&t.createElement("a",{href:"",onClick:this._toggleShowDetails},n?"Hide":"Show"," details"),!isNaN(y)&&n&&this._formatAllNodeDetails(e)))}});var ct=i("0j5jZleo"),xt=Object.defineProperty,At=(e,n,s)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,W=(e,n,s)=>(At(e,typeof n!="symbol"?n+"":n,s),s);class ut extends t.Component{constructor(){super(...arguments),W(this,"_deleteStaticField",n=>()=>{window.confirm(`Are you sure you want to remove static field '${n}' from '${this.props.input.title}'?`)&&ct.Q.destroy(this.props.input,n)}),W(this,"_deleteButton",n=>t.createElement(r.Button,{bsStyle:"link",bsSize:"xsmall",style:{verticalAlign:"baseline"},onClick:this._deleteStaticField(n)},t.createElement(a.JO,{name:"remove"}))),W(this,"_formatStaticFields",n=>{const s=[];return Object.keys(n).forEach(l=>{s.push(t.createElement("li",{key:`${l}-field`},t.createElement("strong",null,l,":")," ",n[l]," ",this._deleteButton(l)))}),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)))}}W(ut,"propTypes",{input:p().object.isRequired});const dt=ut;var Mt=i("8fnsnG21");const tt=({global:e=!1,node:n,onChange:s})=>{const{nodes:o}=(0,Mt.o)(at.S),[l,u]=(0,t.useState)(e),[d,E]=(0,t.useState)(n);(0,t.useEffect)(()=>{if(!n&&o){const P=Object.keys(o);P.length===1&&(s("node",P[0]),E(P[0]))}},[o]);const y=(0,t.useCallback)(P=>{const et=P.target.checked;u(et),et?(E("placeholder"),s("node",void 0)):s("node",d),s("global",et)},[s,d,E,u]),A=(0,t.useCallback)(P=>{E(P.target.value),s("node",P.target.value)},[E,s]);if(!o)return t.createElement(a.$j,null);const $=Object.keys(o).map(P=>t.createElement("option",{key:P,value:P},o[P].short_node_id," / ",o[P].hostname)),D=l?null:t.createElement(r.Input,{id:"node-select",type:"select",label:"Node",placeholder:"placeholder",value:n,help:"On which node should this input start",onChange:A,required:!0},t.createElement("option",{key:"placeholder",value:""},"Select Node"),$);return t.createElement("span",null,t.createElement(r.Input,{id:"global-checkbox",type:"checkbox",label:"Global",help:"Should this input start on all nodes",checked:l,onChange:y}),D)};tt.propTypes={global:p().bool,onChange:p().func.isRequired,node:p().string},tt.defaultProps={global:!1,node:void 0};const mt=tt;var Ot=Object.defineProperty,Ft=(e,n,s)=>n in e?Ot(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,J=(e,n,s)=>(Ft(e,typeof n!="symbol"?n+"":n,s),s);class ht 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();ct.Q.create(this.props.input,s,o).then(()=>this.close())}),this.state={showModal:!1}}render(){return t.createElement(r.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(r.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(r.Input,{ref:n=>{this.fieldValue=n},type:"text",id:"field-value",label:"Field value",required:!0}))}}J(ht,"propTypes",{input:p().object.isRequired});const ft=ht},h0mKhxLv:(w,R,i)=>{i.d(R,{c:()=>T});var t=i("JnTtTRmZ"),I=i.n(t),p=i("jAGDuYSC"),v=i("MdYBRjRJ"),h=i("U1Iufsob"),_=i("eFxcQyPT"),m=i("IA3Ku5lS");const T=(0,m.dS)("core.InputStates",()=>I().createStore({listenables:[],init(){this.list()},getInitialState(){return{inputStates:this.inputStates}},list(){const c=v.DC(h.Z.ClusterInputStatesController.list().url);return(0,_.ZP)("GET",c).then(r=>{const a={};return Object.keys(r).forEach(f=>{r[f]&&r[f].forEach(S=>{a[S.id]||(a[S.id]={}),a[S.id][f]=S})}),this.inputStates=a,this.trigger({inputStates:this.inputStates}),a})},_checkInputStateChangeResponse(c,r,a){const f=Object.keys(r).filter(x=>c.global?!0:x===c.node),S=f.filter(x=>r[x]===null);S.length===0?p.Z.success(`Request to ${a.toLowerCase()} input '${c.title}' was sent successfully.`,`Input '${c.title}' will be ${a==="START"?"started":"stopped"} shortly`):S.length===f.length?p.Z.error(`Request to ${a.toLowerCase()} input '${c.title}' failed. Check your Graylog logs for more information.`,`Input '${c.title}' could not be ${a==="START"?"started":"stopped"}`):p.Z.warning(`Request to ${a.toLowerCase()} input '${c.title}' failed in some nodes. Check your Graylog logs for more information.`,`Input '${c.title}' could not be ${a==="START"?"started":"stopped"} in all nodes`)},start(c){const r=v.DC(h.Z.ClusterInputStatesController.start(c.id).url);return(0,_.ZP)("PUT",r).then(a=>(this._checkInputStateChangeResponse(c,a,"START"),this.list(),a),a=>{p.Z.error(`Error starting input '${c.title}': ${a}`,`Input '${c.title}' could not be started`)})},stop(c){const r=v.DC(h.Z.ClusterInputStatesController.stop(c.id).url);return(0,_.ZP)("DELETE",r).then(a=>(this._checkInputStateChangeResponse(c,a,"STOP"),this.list(),a),a=>{p.Z.error(`Error stopping input '${c.title}': ${a}`,`Input '${c.title}' could not be stopped`)})}}))},wToqYuKZ:(w,R,i)=>{i.d(R,{W:()=>T,_:()=>m});var t=i("JnTtTRmZ"),I=i.n(t),p=i("MdYBRjRJ"),v=i("eFxcQyPT"),h=i("jAGDuYSC"),_=i("IA3Ku5lS");const m=(0,_.ei)("core.InputTypes",()=>I().createActions({list:{asyncResult:!0},get:{asyncResult:!0}})),T=(0,_.dS)("core.InputTypes",()=>I().createStore({listenables:[m],sourceUrl:"/system/inputs/types",inputTypes:void 0,inputDescriptions:void 0,init(){this.list()},getInitialState(){return{inputTypes:this.inputTypes,inputDescriptions:this.inputDescriptions}},list(){const c=(0,v.ZP)("GET",(0,p.DC)(this.sourceUrl)),r=(0,v.ZP)("GET",(0,p.DC)(`${this.sourceUrl}/all`)),a=Promise.all([c,r]);a.then(([f,S])=>{this.inputTypes=f.types,this.inputDescriptions=S,this.trigger(this.getInitialState())},f=>{h.Z.error(`Fetching Input Types failed with status: ${f}`,"Could not retrieve Inputs")}),m.list.promise(a)},get(c){const r=(0,v.ZP)("GET",(0,p.DC)(`${this.sourceUrl}/${c}`));r.catch(a=>{h.Z.error(`Fetching input ${c} failed with status: ${a}`,"Could not retrieve input")}),m.get.promise(r)}}))},"1/PeS1Oa":(w,R,i)=>{i.d(R,{Q:()=>h,d:()=>v});var t=i("9oVghaOd"),I=i.n(t),p=i("4E3oowBb");function v(_,m,T="asc"){const c=I()(_),r=I()(m);return T==="asc"?c.isBefore(r)?-1:r.isBefore(c)?1:0:r.isBefore(c)?-1:c.isBefore(r)?1:0}function h(_,m,T="asc"){return T==="asc"?(0,p.S)(_.toLowerCase(),m.toLowerCase()):(0,p.S)(m.toLowerCase(),_.toLowerCase())}}}]);})();

//# sourceMappingURL=1255d548-5299.82092a4c17aee48064a9.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy