Skip to main content

Set Up Your Data Collection

Using the following scenario as an example, let's setup your automatic data collection and diagnosis.

  • When "error 1" phrase appears in the log of the device 'dev-A', the log file will be uploaded and create a record. Additionaly, a moment will be created at the exact time this phrase happened.

Prerequisites

  1. Have a device ready.
  2. Create a project named auto-upload.
  3. Make sure your role in the coScene organization is "Administrator". If you're not an administrator, contact your organizational admin to update your role. org-role

Adding Rules to Your Project

  1. Navigate to the auto-upload project we just created. pro-1

  2. Within the project, go to the 'Manage Project - Data Collection and Diagnosis Rules' page and click on "Add Rule Group". pro-rule-1

  3. Clear any default content in the rules section. Copy the following rule and paste it into the editor:

    name: error series # Rule group name

    rules:
    - when:
    - has(msg.message, "error 1") # Trigger condition: log contains the string "error 1"
    actions:
    - upload(title="Localization lost - error 1") # Create a record named "Localization lost - error 1" and upload the log file to this record
    - create_moment(title="Localization lost") # Create a moment named "Localization lost"

    enabled: true # Rule group status: enabled

    version: v1 # The current rule group version is only v1

    *For more rule styles, see Structure and Examples of Rules.

  4. Click the "Save" button.

    pro-rule-4


Configure Data Collection Device Information

  1. Go to the "Devices" tab on the organization management page, and click the "Edit Data Collection Rules" button.

    org-device-1

  2. Clear the default content in the rules, then copy and paste the following rule into the editor:

    mod:
    name: 'default' # mod name, default is "default". For custom versions, please contact coScene product for more details.
    conf:
    enabled: true # Whether to enable, default is true.

    # Monitored directories on the device, specified for data collection tasks and rule collection in the project
    base_dirs:
    - /home/bag/
    - /home/log/

    *For more configurations, refer to Data Collection Rule Format

  3. Click the "Save Changes" button.

    org-device-7


Authorizing Device

Using a Linux device as an example, for other device registration methods refer to Device Registration


  1. Open the device terminal, execute the following command, enter the password to switch to root.

    sudo su
  2. In terminal, create folders to be monitored /root/logs

    mkdir logs
  3. In coScene Web, enter the Device tab in the Org management page

    org-device

  4. Copy the installation command, and paste it to the terminal input as Root user

    org-device-copy-command

  5. Run the script, and checkout the system logs

     journalctl -fu cos
    • when you see the following logs, the installation is completed and wait to be permitted by the admins

      dev-install-1

  6. In the device page of the Org settings page, find the to be permitted device, and click "Permit"

    org-device-authorize


Write Files in the Device Monitoring Directory

  1. Ensure the device has received the data collection and diagnostic rules:

    • When the following entry appears in the logs, it indicates that the rules have been successfully acquired:

      rule-log-1

  2. Click to download the dev-A.log generated by device dev-A. Its contents are as follows:

    2023-09-01 11:28:47.000 INFO "Demo Log message 1"
    2023-09-01 11:28:48.000 INFO "Demo Log message 2"
    2023-09-01 11:28:49.000 INFO "Demo Log message 3"
    2023-09-01 11:28:50.000 WARN "Demo Log message 4"
    2023-09-01 11:28:51.000 INFO "Demo Log message 5"
    2023-09-01 11:28:52.000 INFO "Demo Log message 6"
    2023-09-01 11:28:53.000 INFO "Demo Log message 7"
    2023-09-01 11:28:54.000 INFO "Demo Log message 8"
    2023-09-01 11:28:55.000 INFO "Demo Log message 9"
    2023-09-01 11:28:56.000 INFO "Demo Log message 10"
    2023-09-01 11:28:57.000 WARN "Demo Log message 11"
    2023-09-01 11:28:58.000 ERROR "Demo Log message 12 error 1"
    2023-09-01 11:28:59.000 INFO "Demo Log message 13"
    2023-09-01 11:29:00.000 INFO "Demo Log message 14"
    2023-09-01 11:29:01.000 INFO "Demo Log message 15"
    2023-09-01 11:29:02.000 INFO "Demo Log message 16"
    2023-09-01 11:29:03.000 INFO "Demo Log message 17"
    2023-09-01 11:29:04.000 INFO "Demo Log message 18"
    2023-09-01 11:29:05.000 INFO "Demo Log message 19"
    2023-09-01 11:29:06.000 INFO "Demo Log message 20"
  3. In your terminal, execute the command to copy the file dev-A.log to the /root/logs/ directory on the device.

    scp Downloads/dev-A.log root@ubuntu:/root/logs

    # Where Downloads/dev-A.log is the directory where the dev-A.log file is located on the local machine, and root@ubuntu is the device name. Both need to be modified accordingly.
  4. Log Data Upload

    • When the following entry appears in the logs, it indicates that the log data is being uploaded to the coScene platform.

      rule-log-2


View the Created Record

  1. Enter the auto-upload project.

    pro-1

  2. View the automatically created record.

    auto-record-1

  3. Check the data uploaded in the record.

    auto-record-2

  4. View the moment created at the trigger time.

    auto-record-3