Created
November 24, 2021 09:34
-
-
Save marcusschiesser/4c3d3f247fc0f1d7e848b283b53c10ad to your computer and use it in GitHub Desktop.
How to programmatically connect a search datasource to a Splunk visualization (without using the dashboard)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react'; | |
import Table from '@splunk/visualizations/Table'; | |
import { SplunkSearch } from '@splunk/datasources'; | |
const DSTable = () => { | |
const [dsResult, setDsResult] = useState(null); | |
const ds = new SplunkSearch({ | |
query: '| inputlookup example_kv', | |
queryParameters: { | |
earliest: '0', | |
}, | |
}); | |
ds.setup(); | |
ds.request({ offset: 0, count: 10 })({ | |
next: (x) => setDsResult(x), | |
error: (err) => console.error(err), | |
complete: () => console.log('Observer got a complete'), | |
}); | |
return ( | |
<Table options={{}} dataSources={{ primary: dsResult }} /> | |
); | |
}; | |
DSTable.config = { | |
key: 'splunk.DSTable', | |
name: 'DSTable', | |
}; | |
DSTable.propTypes = {}; | |
DSTable.defaultProps = {}; | |
export default DSTable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment