AIOps

AIOps

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

AIOps - Topology Manager - update file-observer file before each run via command line

By Krishna Kodali posted Wed March 02, 2022 01:39 PM

  

Observer: File-Observer, Environment: AIOps - Topology Manager/ASM running on OCP.

Ask - How to update/overwrite existing file-observer file before each run via command line?

This one is a 3 step process :
1) Identify unique_id of the existing observer job 
2) Replace the existing file using either same/different file name
3) Run the job using the values of 1st and 2nd steps.

1) Find out the unique_id of the existing job, in this example, it’s called ‘first-vcenter.txt’., then you’ll need to know the provider, in this case it’s ‘NCIM1’.



2) Replace the existing file using either same/different file name 

The syntax for curl, and list of all possible parameters can be found at swagger ui , you can find respective URL at - https://www.ibm.com/docs/en/nasm/1.1.10?topic=reference-swagger

 

In my example, the URL for file-observer is: https://noi-topology.noi.apps.hybrid.cp.fyre.ibm.com/1.0/file-observer/swagger#!/ . You can find syntax reference under ‘Files -> PUT’ section on how to overwrite, rename files using cURL:



As stated in above screen-shot, if you are trying to replace existing file, you can’t use POST, you’ll end up with below error:

# curl -Ls -k -u $ASM_USER:$ASM_PASS -X POST --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --url 'https://noi-topology.noi.apps.hybrid.cp.fyre.ibm.com/1.0/file-observer/files' --form 'job_file=@/tmp/ first-vcenter.txt;filename=first-vcenter.txt’

{"_error":{"message":"File already exist.","level":"warning"}}

Here is the syntax you should use to overwrite existing file using ‘PUT’: 

# curl -Ls -k -u $ASM_USER:$ASM_PASS -X PUT --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' --url 'https://noi-topology.noi.apps.hybrid.cp.fyre.ibm.com/1.0/file-observer/files' --form 'job_file=@/tmp/ first-vcenter.txt;filename=first-vcenter.txt'

["Updated successfully"]

3) One the file is updated, you can kick off job via CLI using following:

#curl -Ls -k -u $ASM_USER:$ASM_PASS -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'X-TenantID: cfd95b7e-3bc7-4006-a4a8-a73a79c71255' -d '{ "unique_id": "first-vcenter.txt", "parameters": { "provider": "NCIM1", "file": "first-vcenter.txt"}, "scheduleRequest": true }' 'https://noi-topology.noi.apps. hybrid.cp.fyre.ibm.com/1.0/file-observer/jobs/load'

You can validate job history via UI by navigating to specific observer job:




Or if you want to track via log – you could run following to confirm job status:

# oc logs -f noi-topology-file-observer-5c89f47665-r6tb6 | grep FINISHED

INFO   [2022-03-02 17:55:46,137] [cfd95b7e-3bc7-4006-a4a8-a73a79c71255:first-vcenter.txt] c.i.i.t.o.p.e.EndOfObservation -  cfd95b7e-3bc7-4006-a4a8-a73a79c71255:first-vcenter.txt Waiting for state FINISHED

INFO   [2022-03-02 17:55:46,580] [pool-12-thread-2] c.i.i.t.o.p.e.EndOfObservation -  cfd95b7e-3bc7-4006-a4a8-a73a79c71255:first-vcenter.txt Kafka message detected state change from FINISHING to FINISHED


#howto
#topologymanager
#Topology
#ASM
#observer
#upgrade
#install
#setup
#CloudPakforWatsonAIOps
0 comments
94 views

Permalink