Feb-09-2022, 08:26 AM
Hello ,
I am trying to update values in in dict that construct from nested dict and list the dict as follows
I can get the values of the desired keys as shown below but don't know how to update them
Please advice
Thanks
I am trying to update values in in dict that construct from nested dict and list the dict as follows
1 |
dict_file = { 'job_name' : 'system' , 'static_configs' : [{ 'targets' : [ 'localhost' ], 'labels' : { 'job' : 'varlogs' , '__path__' : '/var/log/*log' , 'host' : 'grafana' }}]} |
1 2 3 |
job_name = dict_file.get( 'job_name' ) host_name = dict_file.get( 'static_configs' )[ 0 ].get( 'labels' ).get( 'host' ) path_name = dict_file.get( 'static_configs' )[ 0 ].get( 'labels' ).get( '__path__' ) |
Thanks