MDR Splunk SAF Offboarding Notes.txt 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. MDR Splunk SAF Data Offboarding.txt
  2. Currently a 3 node multi-site cluster. Possible solution, set search and rep factor to 3 and 3 then pull the index files off one of the indexers to a new instance. On the new instance, setup multi-site cluster with one site and see if you can read the indexed files.
  3. https://docs.splunk.com/Documentation/Splunk/8.0.2/Indexer/Decommissionasite
  4. https://docs.splunk.com/Documentation/Splunk/7.0.3/Indexer/Multisitedeploymentoverview
  5. 1 - cluster master
  6. 1 - indexer with search
  7. /opt/splunkdata/hot/normal_primary/
  8. indexes:
  9. app_mscas
  10. app_o365
  11. dns
  12. forescout
  13. network
  14. security
  15. te
  16. File paths
  17. #Where in salt are the search / rep factors
  18. salt/pillar/saf_variables.sls
  19. splunk:
  20. cluster_name: saf
  21. license_master: saf-splunk-cm
  22. idxc:
  23. label: "saf_index_cluster"
  24. pass4SymmKey: "$1$ekY601SK1y5wfbd2ogCNRIhn+gPeQ+UYKzY3MMAnPmmz"
  25. rep_factor: 2
  26. search_factor: 2
  27. #where in splunk are the configs written to?
  28. /opt/splunk/etc/system/local/server.conf
  29. [clustering]
  30. mode = master
  31. multisite = true
  32. replication_factor = 2
  33. search_factor = 2
  34. max_peer_sum_rep_load = 15
  35. max_peer_rep_load = 15
  36. max_peer_build_load = 6
  37. summary_replication = true
  38. site_search_factor = origin:1, total:2
  39. site_replication_factor = origin:1,site1:1,site2:1,site3:1,total:3
  40. available_sites = site1,site2,site3
  41. cluster_label = afs_index_cluster
  42. Steps
  43. 1. change /opt/splunk/etc/system/local/server.conf site_search_factor to origin:1,site1:1,site2:1,site3:1,total:3 This will ensure we have a searchable copy of all the buckets on all the sites. Should I change site_replication_factor to origin:1, total:1? this would reduce the size of the index.
  44. 2. restart CM ( this will apply the site_search_factor )
  45. 3. send data to junk index (oneshot)
  46. 3.1 /opt/splunk/bin/splunk add oneshot /opt/splunk/var/log/splunk/splunkd.log -sourcetype splunkd -index junk
  47. 4. stop one indexer and copy index to new cluster.
  48. 5. on new cluster, setup CM and 1 indexer in multisite cluster. the clustermaster will be a search head in the same site
  49. 6. setup new cluster to have site_mappings = default:site1
  50. 7. attempt to search on new cluster
  51. made the new junk index on test saf
  52. number of events: 64675
  53. latest = 02/21/20 9:32:01 PM UTC
  54. earlest = 02/19/20 2:32:57 PM UTC
  55. Before copying the buckets, ensure they are ALL WARM buckets, HOT buckets maybe be deleted on startup.
  56. #check on the buckets
  57. | dbinspect index=junk
  58. uploaded brad_LAN key pair to AWS for new instances.
  59. vpc-041edac5e3ca49e4d
  60. subnet-0ca93c00ac57c9ebf
  61. sg-0d78af22d0afd0334
  62. saf-offboarding-cm-deleteme
  63. saf-offboarding-indexer-1-deleteme
  64. CentOS 7 (x86_64) - with Updates HVM
  65. t2.medium (2 CPU 4 GB RAM)
  66. 100 GB drive
  67. msoc-default-instance-role
  68. saf-offboarding-ssh Security group <- delete this not needed just SSH from Bastion host
  69. splunk version 7.0.3
  70. setup proxy for yum and wget
  71. vi /etc/yum.conf
  72. proxy=http://proxy.msoc.defpoint.local:80
  73. yum install vim wget
  74. vim /etc/wgetrc
  75. http_proxy = http://proxy.msoc.defpoint.local:80
  76. https_proxy = http://proxy.msoc.defpoint.local:80
  77. Download Splunk
  78. wget -O splunk-7.0.3-fa31da744b51-linux-2.6-x86_64.rpm 'https://www.splunk.com/page/download_track?file=7.0.3/linux/splunk-7.0.3-fa31da744b51-linux-2.6-x86_64.rpm&ac=&wget=true&name=wget&platform=Linux&architecture=x86_64&version=7.0.3&product=splunk&typed=release'
  79. install it
  80. yum localinstall splunk-7.0.3-fa31da744b51-linux-2.6-x86_64.rpm
  81. #setup https
  82. vim /opt/splunk/etc/system/local/web.conf
  83. [settings]
  84. enableSplunkWebSSL = 1
  85. #start it
  86. /opt/splunk/bin/splunk start --accept-license
  87. #CM
  88. https://10.1.2.170:8000/en-US/app/launcher/home
  89. #Indexer
  90. https://10.1.2.236:8000/en-US/app/launcher/home
  91. Change password for admin user
  92. /opt/splunk/bin/splunk edit user admin -password Jtg0BS0nrAyD -auth admin:changeme
  93. Turn on distributed search in the GUI
  94. #on CM
  95. /opt/splunk/etc/system/local/server.conf
  96. [general]
  97. site = site1
  98. [clustering]
  99. mode = master
  100. multisite = true
  101. replication_factor = 2
  102. search_factor = 2
  103. max_peer_sum_rep_load = 15
  104. max_peer_rep_load = 15
  105. max_peer_build_load = 6
  106. summary_replication = true
  107. site_search_factor = origin:1,site1:1,site2:1,site3:1,total:3
  108. site_replication_factor = origin:1,site1:1,site2:1,site3:1,total:3
  109. available_sites = site1,site2,site3
  110. cluster_label = saf_index_cluster
  111. pass4SymmKey = password
  112. site_mappings = default:site1
  113. #on IDX
  114. /opt/splunk/etc/system/local/server.conf
  115. [general]
  116. site = site1
  117. [clustering]
  118. master_uri = https://10.1.2.170:8089
  119. mode = slave
  120. pass4SymmKey = password
  121. [replication_port://9887]
  122. ***ensure networking is allowed between the hosts***
  123. The indexer will show up in the Cluster master
  124. #create this file on the indexer
  125. /opt/splunk/etc/apps/saf_all_indexes/local/indexes.conf
  126. [junk]
  127. homePath = $SPLUNK_DB/junk/db
  128. coldPath = $SPLUNK_DB/junk/colddb
  129. thawedPath = $SPLUNK_DB/junk/thaweddb
  130. #copy the index over to the indexer
  131. cp junk_index.targz /opt/splunk/var/lib/splunk/
  132. tar -xzvf junk_index.targz
  133. ###################################################################################
  134. PROD testing Notes
  135. SAF PROD Cluster testing with the te index.
  136. The indexers do not have the space to move to search/rep factor 3/3. Duane suggests keeping the current 2/3 and letting the temp splunk cluster make the buckets searchable. according to the monitoring console:
  137. te index gathered on Feb 26
  138. total index size: 3.1 GB
  139. total raw data size uncompressed: 10.37 GB
  140. total events: 12,138,739
  141. earliest event: 2019-05-17 20:40:00
  142. latest event: 2020-02-26 16:43:32
  143. | dbinspect index=te | stats count by splunk_server
  144. count of buckets
  145. indexer1: 105
  146. indexer2: 103
  147. indexer3: 104
  148. | dbinspect index=te | search state=hot
  149. currently 6 hot buckets
  150. index=te | stats count ALL TIME fast mode
  151. 6069419
  152. size on disk
  153. 1.1 GB
  154. size of tarball
  155. 490 MB
  156. Allow instance to write to S3 bucket
  157. {
  158. "Id": "Policy1582738262834",
  159. "Version": "2012-10-17",
  160. "Statement": [
  161. {
  162. "Sid": "Stmt1582738229969",
  163. "Action": [
  164. "s3:PutObject"
  165. ],
  166. "Effect": "Allow",
  167. "Resource": "arn:aws:s3:::mdr-saf-off-boarding/*",
  168. "Principal": {
  169. "AWS": [
  170. "arn:aws:iam::477548533976:role/msoc-default-instance-role"
  171. ]
  172. }
  173. }
  174. ]
  175. }
  176. ./aws s3 cp rst2odt.py s3://mdr-saf-off-boarding
  177. ./aws s3 cp /opt/splunkdata/hot/normal_primary/saf_te_index.tar.gz s3://mdr-saf-off-boarding
  178. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_te_index.tar.gz --expires-in 604800
  179. uploaded brad_LAN key pair to AWS for new instances.
  180. vpc-0202aedf3d0417cd3
  181. subnet-01bc9f77742ff132d
  182. sg-03dcc0ecde42fc8c2, sg-077ca2baaca3d8d97
  183. saf-offboarding-splunk-cm
  184. saf-offboarding-splunk-indexer
  185. CentOS 7 (x86_64) - with Updates HVM
  186. t2.medium (2 CPU 4 GB RAM)
  187. 100 GB drive for te index test
  188. msoc-default-instance-role
  189. tag instances
  190. Client saf
  191. use the msoc_build key
  192. #CM
  193. ip-10-1-3-72
  194. #indexer-1
  195. ip-10-1-3-21
  196. #indexer-2
  197. ip-10-1-3-24
  198. #indexer-3
  199. ip-10-1-3-40
  200. use virtualenv to grab awscli
  201. export https_proxy=http://proxy.msoc.defpoint.local:80
  202. sudo -E ./pip install awscli
  203. ./aws s3 cp s3://mdr-saf-off-boarding/saf_te_index.tar.gz /opt/splunk/var/lib/splunk/saf_te_index.tar.gz
  204. move index to CM rep buckets are not expanding to Search buckets
  205. 1. rm -rf saf_all_indexes
  206. 2. create it on the CM
  207. 2.1 mkdir -p /opt/splunk/etc/master-apps/saf_all_indexes/local/
  208. 2.2 vim /opt/splunk/etc/master-apps/saf_all_indexes/local/indexes.conf
  209. [te]
  210. homePath = $SPLUNK_DB/te/db
  211. coldPath = $SPLUNK_DB/te/colddb
  212. thawedPath = $SPLUNK_DB/te/thaweddb
  213. repFactor=auto
  214. 2.3 cluster bundle push
  215. 2.3.1 /opt/splunk/bin/splunk list cluster-peers
  216. 2.3.1 splunk validate cluster-bundle
  217. 2.3.2 splunk apply cluster-bundle
  218. ###################
  219. #
  220. # Actual PROD offboarding!
  221. #
  222. ##################
  223. #estimate size and age
  224. | rest /services/data/indexes/
  225. | search title=app_mscas OR title = app_o365 OR title=dns OR title=forescout OR title=network OR title=security OR title=Te
  226. | eval indexSizeGB = if(currentDBSizeMB >= 1 AND totalEventCount >=1, currentDBSizeMB/1024, null())
  227. | eval elapsedTime = now() - strptime(minTime,"%Y-%m-%dT%H:%M:%S%z")
  228. | eval dataAge = ceiling(elapsedTime / 86400)
  229. | stats sum(indexSizeGB) AS totalSize max(dataAge) as oldestDataAge by title
  230. | eval totalSize = if(isnotnull(totalSize), round(totalSize, 2), 0)
  231. | eval oldestDataAge = if(isNum(oldestDataAge), oldestDataAge, "N/A")
  232. | rename title as "Index" totalSize as "Total Size (GB)" oldestDataAge as "Oldest Data Age (days)"
  233. 1. adjust CM and push out new data retention limits per customer email
  234. 2. allow indexers to prune old data
  235. 3. stop splunk on one indexer
  236. 4. tar up splunk directory
  237. 5. upload to s3
  238. 6. download from s3 to temp indexers and extract to ensure data is readable
  239. 7. repeat for all indexes
  240. prune data based on time
  241. Updated Time
  242. 1/6/2020, 1:59:50 PM
  243. Active Bundle ID?
  244. 73462849B9E88F1DB2B9C60643A06F67
  245. Latest Bundle ID?
  246. 73462849B9E88F1DB2B9C60643A06F67
  247. Previous Bundle ID?
  248. FF9104B61366E1841FEDB1AF2DE901C2
  249. 4
  250. With encryption
  251. tar cvzf saf_myindex_index.tar.gz myindex/
  252. without encryption
  253. tar cvf /hubble.tar hubble/
  254. trying this: https://github.com/jeremyn/s3-multipart-uploader
  255. use virtualenv
  256. bin/python s3-multipart-uploader-master/s3_multipart_uploader.py -h
  257. bucket name mdr-saf-off-boarding
  258. bin/aws s3 cp /opt/splunkdata/hot/saf_te_index.tar.gz s3://mdr-saf-off-boarding/saf_te_index.tar.gz
  259. DID NOT NEED TO USE THE MULTIPART uploader!
  260. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_app_mscas_index.tar.gz --expires-in 86400
  261. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_app_o365_index.tar.gz --expires-in 86400
  262. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_dns_index.tar.gz --expires-in 86400
  263. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_forescout_index.tar.gz --expires-in 86400
  264. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_network_index.tar --expires-in 86400
  265. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_security_index.tar.gz --expires-in 86400
  266. aws --profile=mdr-prod s3 presign s3://mdr-saf-off-boarding/saf_te_index.tar.gz --expires-in 86400