1
votes

I'm trying to access IBM provided logDNA without logging in IBM console and traversing to LogDNA Dashboard location

I've no clue on how to proceed with this.

curl "https://logs.logdna.com/logs/ingest?hostname=EXAMPLE_HOST&mac=C0:FF:EE:C0:FF:EE&ip=10.0.1.101&now=$(date +%s)" \
-u INSERT_INGESTION_KEY: \
-H "Content-Type: application/json; charset=UTF-8" \
-d \
'{
   "lines": [
     {
       "line":"This is an awesome log statement",
       "app":"myapp",
       "level": "INFO",
       "env": "production",
       "meta": {
         "customfield": {
           "nestedfield": "nestedvalue"
         }
       }
     }
   ]
}'

In the above code snippet the URL used is generic URL, instead of that I want to generate a URL for my IBM LogDNA which should be accessible through access token, so that I can use below type code snippet to push the logs to logDNA directly from the code.

Currently to open LogDNA dashboard, I login to IBM cloud UI and check in Observability section. Is there a way we can access this through tokens and have a custom URL on which I can apply this?

2

2 Answers

2
votes

The steps to obtain the dashboard URL using the command line are described in the related IBM Cloud Logging service documentation. This works for the Activity Tracker the same way:

$ ibmcloud resource service-instance your-instance-name --output json | jq -r '.[0].dashboard_url'
0
votes

LogDNA documentation about REST ingestion is amazing... But their service is really amazing. And this works for me:

In LogDNA dashboard, at [Settings -> Organization -> API Keys] you can find your key.

Let's say, you key is 77777haha77777777777hoho.

In you curl command replace the second row with this:

-u "77777haha77777777777hoho:77777haha77777777777hoho" \

Entire tested command:

curl "https://logs.logdna.com/logs/ingest? 
hostname=EXAMPLE_HOST&mac=C0:FF:EE:C0:FF:EE&ip=10.0.1.101&now=1610830847530" \
-u "77777haha77777777777hoho:77777haha77777777777hoho" \
-H "Content-Type: application/json; charset=UTF-8" \
-d \
'{
  "lines":[
    {
        "timestamp":1610830847530,
        "line":"This is an awesome log statement",
        "file":"example.log"
    }
  ]
}'