OUTDATED

This part of the documentation is currently not up to date!

Please refer to our Python example in the meantime.

Exporting Logs With Rust

Export Onna Logs As JSON With Rust


💡 3 min read

Disclaimer

This guide is written for Linux and macOS, depending on your Operating System you may need to adjust.

This guide is based on Rust, tested using cargo 1.43.0 and uses the hosted Onna SaaS platform.

This guide also assumes some familiarity with Rust, if you're interested please see - Rust and Rustlings interactive tutorial.

# Requirements

Note

Make sure that the version of Rust is up to date via rustup update stable.

The hosted platforms (e.g https://$COMPANY.onna.io or https://enterprise.onna.com/$COMPANY) only require HTTP requests.

If Python is more to your liking check out export-logs

# Prerequisite

The activitylog endpoint requires specific permissions.

If you want to run this script unattended, like as a cron job, the user account used to authenticate must be a Service Account.

Please contact Onna support (support [at] onna [dot] com) for assistance with setting up a Service Account.

Note

To be able to export data from your Onna instance, you'll need the following credentials:

USERNAME: Service Account or username
PASSWORD: password
ACCOUNT: the Onna account name
ACCOUNT_URL: the URL of your account, e.g https://$COMPANY.onna.io or https://enterprise.onna.com/$COMPANY

# Setup

Create a directory for the script and its dependencies

mkdir $DIR #choose a name for the directory
1

Change into the newly created directory

cd $DIR
1

Download the onna-logs archive with source code and dependencies and expand it.

Build the script:

cargo build
1

Running onna-logs script requires some args:

cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
    Running `target/debug/onna-logs`
error: The following required arguments were not provided:
    --account <account>
    --account-url <account-url>
    --fname <fname>
    --from-date <from-date>
    --password <password>
    --to-date <to-date>
    --username <username>

USAGE:
    onna-logs --account <account> --account-url <account-url> --container <container> --fname <fname> --from-date <from-date> --password <password> --to-date <to-date> --username <username>

For more information try --help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# Syntax

./target/debug/onna-logs --account $ACCOUNT --account_url $ACCOUNT_URL  --container $CONTAINER --fname $FNAME\ --from_date $FROM_DATE --password $PASSWORD --to_date $TO_DATE --username $USERNAME
1

Note

[--container $CONTAINER] refers to the container holding all your data in the Onna instance.

For Onna accounts in the enterprise.onna.com namespace, the container name is the same as your account name. If your Onna account has its own subdomain and you don't know your container name, please contact support for assistance.

Please contact Onna support (support [at] onna [dot] com) if you need assistance.

# Example

./target/debug/onna-logs --account account --account-url https://enterprise.onna.com \
--container example --fname example-audit --from-date 2020-01-01 \
--password <secret-password> --to-date 2020-01-20 --username example1
1
2
3

Running the script will do the following:

It will export all audit logs from the 01-01-2020 till the 01-20-2020 of the account example running on https://enterprise.onna.com to /tmp/example-audit.json.

The script uses the username example1 with the password 1234.

Last Updated: 7/20/2020, 9:27:57 AM