OUTDATED

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

Please refer to our Python example in the meantime.

Export logs with Rust

Learn how to export the logs as a JSON file using Rust


💡 3 min read

Info

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

  • Rust

Info

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.

# 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 support[at]onna.com for assistance with setting up a Service Account.

Info

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 sample file 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

Info

[--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 support[at]onna.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: 11/13/2020, 8:17:00 AM