This Guide will give you an example on how to setup and upload data into jaindb and do some basic reporting. In the following examples, Inventory data is used as data source. But jaindb is not limited to inventory data, you can upload whatever you want... but no everything makes sense... Jaindb is using a blockchain to guarantee the integrity of the data which is great for Inventory/Asset data where you want to keep an auditable history for a long time.
Windows 10 Servicing example by using Power-BI with jaindb:
Pre-Requisites for Windows
- Windows 10 (>1703) or Server 2016 with the "Container" feature installed
- Internet connection to download the docker image
- Directory on the Host to store the Redis-Database and configuration Files ("D:\jaindb" in my examples)
Get the latest Version of the jaindb image:
docker pull zanderr/jaindb
The Docker-Variable "localURL" must point to the public URL of the published container (internal Port TCP:5000). In my example, I will publish the internal Port TCP:5000 to the public Port TCP:5000, so the URl is my IP of the host on port 5000.
If you want to query the Redis-DB directly, you should publish Port 6379 as well.
Finally, let's redirect the internal path /app/wwwroot to an external directory d:\jaindb. This will redirect all important data to a directory on the host so we can rebuild the container without loosing data...!
Configure and run the container:
docker run --name jaindb -d -e "localURL=http://192.168.2.146" -e "WebPort=5000" -p 5000:5000/tcp -p 6379:6379/tcp -v d:/jaindb:/app/wwwroot zanderr/jaindb
Jaindb is now up and running (hopefully)...
If you want to know more details about the JSON format, check the Wiki-Page: Data-Format
Collect Inventory Data
To feed jaindb, it's very easy to upload some inventory data from windows(10) clients. Just open a PowerShell command as Admin (required to collect System-Information) and run the following command (change the URL to reflect the IP or DNS-name of your Environment!):
Invoke-RestMethod -Uri 'http://192.168.2.146:5000/getps' | iex
The command will get and run the inventory.ps1 PowerShell-Script from your published directory (d:\jaindb in the example).
As a result, you will receive your Device ID and the Hash of your uploaded data:
Device ID: 9qZpJhJqeRB2nZKCjX5i5MV5L 9qZdT7xPUyW7HrpFgq7YKPj4d
jaindb validates your data and appends a new block on the blockchain of your device.
Jaindb provies a REST-API to query the uploaded data. Please check the REST-API reference for all available options.
Note: The following examples are using PowerShell, but you can also use Power-BI or any other tool that can handle JSON results as a reporting tool.
Let's get back the data we have uploaded:
Invoke-RestMethod -Uri "http://192.168.2.146:5000/full?name=$($env:Computername)"
This will return the inventory from cache, so it includes the attributes tagged with '@'
To get the data from the blockchain, we have to specify the index (starting with 1, as 0 is the genesis block):
Invoke-RestMethod -Uri "http://192.168.2.146:5000/full?name=$($env:Computername)&index=1"
To get a list of history data with all the indexes and timestamps for your computer:
Invoke-RestMethod -Uri "http://192.168.2.146:5000/history?name=$($env:Computername)"
If you want to know all current Computer-Names and Operating-Systems in your jaindb:
Invoke-RestMethod -Uri 'http://192.168.2.146:5000/query?OS.Caption,OS.Version&$select=%23Name,_date'
To include historical data to e.g. chart the progress of your Win10 rollout:
Invoke-RestMethod -Uri 'http://192.168.2.146:5000/queryall?OS.Caption,OS.Version&$select=%23Name,_date'
Sometimes it's also important to know what has changed. The current example gets the difference from current data to index 2:
Invoke-RestMethod -Uri "http://192.168.2.146:5000/diff?name=$($env:Computername)&index=2,mode=0"