Primary open-angle glaucoma (POAG) is a common ocular disease, and there is currently no effective treatment for POAG therapy. Thus, identifying some effective diagnostic markers is beneficial to the treatment of patients. The expression profile was obtained from Gene Expression Omnibus (GEO) database. The functional enrichment was analyzed using Gene Ontology, Kyoto Encyclopedia of Genes and Genomes and gene set enrichment analysis. Co-expressed genes were identified using weighted gene co-expression network analysis (WGCNA). Hub genes were screened through Lasso regression, support vector machine-recursive feature elimination (SVM-RFE) and Random Forest, and receiver operating characteristic curve was used to assess diagnostic value. Immune cell infiltration was calculated using IOBR package. The regulatory network was constructed through STRING, miRactDB and Cytoscape. The oncoPredict package was employed to predict the candidate chemotherapy agents. According to GSE27276 database, 541 differentially expressed genes were identified. Five oxidative stress-related genes with high area under the curve value, namely HBB, MAOA, ACOX2, ALDH7A1 and TYMP, were determined using WGCNA and machine learning. Infiltration level of NK cells, CD4 T cells and dendritic cells were significantly increased in POAG group compared with normal group, while CD8 T cells and Tregs cells were significantly decreased. HBB was closely related to most immune cells. Hub genes were all targeted by 16 miRNAs. Drug sensitivity analysis exhibited that some drugs were more sensitivity for POAG, such as Acetalax_1804, Ibrutinib_1799 and OSI_027_1594. We identified 5 oxidative stress-related genes with high diagnostic value for POAG.