Bacterial antimicrobial resistance (AMR) is among the most significant challenges to current human society. Exposing bacteria to antibiotics can activate their self-saving responses, e.g., filamentation, leading to the development of bacterial AMR. Understanding the molecular changes during the self-saving responses can reveal new inhibition methods of drug-resistant bacteria. Herein, we used an online microfluidics mass spectrometry system for real-time characterization of metabolic changes of bacteria during filamentation under the stimulus of antibiotics. Significant pathways, e.g., nucleotide metabolism and coenzyme A biosynthesis, correlated to the filamentation of extended-spectrum beta-lactamase-producing
Escherichia coli
(ESBL-
E. coli
) were identified. A cyclic dinucleotide, c-di-GMP, which is derived from nucleotide metabolism and reported closely related to bacterial resistance and tolerance, was observed significantly up-regulated during the bacterial filamentation. By using a chemical inhibitor, ebselen, to inhibit diguanylate cyclases which catalyzes the synthesis of c-di-GMP, the minimum inhibitory concentration of ceftriaxone against ESBL-
E. coli
was significantly decreased. This inhibitory effect was also verified with other ESBL-
E. coli
strains and other beta-lactam antibiotics, i.e., ampicillin. A mutant strain of ESBL-
E. coli
by knocking out the
dgcM
gene was used to demonstrate that the inhibition of the antibiotic resistance to beta-lactams by ebselen was mediated through the inhibition of the diguanylate cyclase DgcM and the modulation of c-di-GMP levels. Our study uncovers the molecular changes during bacterial filamentation and proposes a method to inhibit antibiotic-resistant bacteria by combining traditional antibiotics and chemical inhibitors against the enzymes involved in bacterial self-saving responses.